'use strict'; var learts; var md=new MobileDetect(window.navigator.userAgent); ( function(){ learts=( function(){ return { init: function(){ this.closeTopBar(); this.offcanvas(); this.backToTop(); this.stickyHeader(); this.splitNavHeader(); this.headerOverlap(); this.verticalHeader(); this.blog(); this.switcher(); this.siteMenu(); this.mobileMenu(); this.search(); this.wishlist(); this.miniCart(); this.shop(); this.quickView(); this.notification(); this.compare(); this.ajaxAddToCart(); this.ajaxLoadMore(); this.product(); this.crossSells(); this.swatches(); this.quantityField(); this.imageCarousel(); this.instagramCarousel(); this.countdown(); this.productCategoriesShortcode(); this.productsShortCode(); this.vcTabs(); this.vcRow(); this.vcColumn(); this.cookie(); this.brand (); this.customJS(); this.instagram(); this.mailchimpSubscribe(); this.menuVertical(); this.menuGrid(); this.bannerCarousel(); this.testimonialCarousel(); }} }() ); } )(jQuery); jQuery(document).ready(function(){ learts.init(); }); ( function(window){ "use strict"; function GridLoaderFx(el, itemClass, callback){ this.el=el; this.items=this.el.querySelectorAll(itemClass); } GridLoaderFx.prototype.effects={ 'Hapi':{ animeOpts: { duration: function(t, i){ return 600 + i * 75; }, easing:'easeOutExpo', delay:function(t, i){ return i * 50; }, opacity:{ value:[0, 1], easing: 'linear' }, scale:[0, 1] }}, 'Amun':{ sortTargetsFn: function(a, b){ var aBounds=a.getBoundingClientRect(), bBounds=b.getBoundingClientRect(); return ( aBounds.left - bBounds.left )||( aBounds.top - bBounds.top ); }, animeOpts:{ duration:function(t, i){ return 500 + i * 50; }, easing:'easeOutExpo', delay:function(t, i){ return i * 20; }, opacity:{ value:[0, 1], duration: function(t, i){ return 250 + i * 50; }, easing:'linear' }, translateY: [400, 0] }}, 'Kek':{ sortTargetsFn: function(a, b){ return b.getBoundingClientRect().left - a.getBoundingClientRect().left; }, animeOpts:{ duration:800, easing:[0.1, 1, 0.3, 1], delay:function(t, i){ return i * 20; }, opacity:{ value:[0, 1], duration: 600, easing:'linear' }, translateX: [- 500, 0], rotateZ:[15, 0] }}, 'Isis':{ animeOpts: { duration:900, elasticity: 500, delay:function(t, i){ return i * 15; }, opacity:{ value:[0, 1], duration: 300, easing:'linear' }, translateX: function(){ return [anime.random(0, 1)===0 ? 100:- 100, 0]; }, translateY: function(){ return [anime.random(0, 1)===0 ? 100:- 100, 0]; }} }, 'Montu':{ perspective: 800, origin:'50% 0%', animeOpts:{ duration:1500, elasticity: 400, delay:function(t, i){ return i * 75; }, opacity:{ value:[0, 1], duration: 1000, easing:'linear' }, rotateX:[- 90, 0] }}, 'Osiris': { perspective: 3000, animeOpts:{ duration:function(){ return anime.random(500, 1000) }, easing:[0.2, 1, 0.3, 1], delay:function(t, i){ return i * 50; }, opacity:{ value:[0, 1], duration: 700, easing:'linear' }, translateZ: { value:[- 3000, 0], duration: 1000 }, rotateY:['-1turns', 0] }}, 'Satet':{ animeOpts: { duration:800, elasticity: 600, delay:function(t, i){ return i * 100; }, opacity:{ value:[0, 1], duration: 600, easing:'linear' }, scaleX:{ value: [0.4, 1] }, scaleY:{ value:[0.6, 1], duration: 1000 }} }, 'Atum':{ sortTargetsFn: function(a, b){ var docScrolls={ top: document.body.scrollTop + document.documentElement.scrollTop }, y1=window.innerHeight + docScrolls.top, aBounds=a.getBoundingClientRect(), ay1=aBounds.top + docScrolls.top + aBounds.height / 2, bBounds=b.getBoundingClientRect(), by1=bBounds.top + docScrolls.top + bBounds.height / 2; return Math.abs(y1 - ay1) - Math.abs(y1 - by1); }, perspective:1000, origin:'50% 0%', animeOpts:{ duration:800, easing:[0.1, 1, 0.3, 1], delay:function(t, i){ return i * 35; }, opacity:{ value:[0, 1], duration: 600, easing:'linear' }, translateX: [100, 0], translateY: [- 100, 0], translateZ: [400, 0], rotateZ:[10, 0], rotateX:[75, 0] }}, 'Ra':{ origin:'50% 0%', animeOpts: { duration:500, easing:'easeOutBack', delay:function(t, i){ return i * 100; }, opacity:{ value:[0, 1], easing: 'linear' }, translateY: [400, 0], scaleY:[{ value:[3, 0.6], delay:function(t, i){ return i * 100 + 120; }, duration: 300, easing:'easeOutExpo' }, { value:[0.6, 1], duration: 1400, easing:'easeOutElastic' }], scaleX:[{ value:[0.9, 1.05], delay:function(t, i){ return i * 100 + 120; }, duration: 300, easing:'easeOutExpo' }, { value:[1.05, 1], duration: 1400, easing:'easeOutElastic' }] }}, 'Sobek':{ animeOpts: { duration:600, easing:'easeOutExpo', delay:function(t, i){ return i * 100; }, opacity:{ value:[0, 1], duration: 100, easing:'linear' }, translateX: function(t, i){ var docScrolls={ left: document.body.scrollLeft + document.documentElement.scrollLeft }, x1=window.innerWidth / 2 + docScrolls.left, tBounds=t.getBoundingClientRect(), x2=tBounds.left + docScrolls.left + tBounds.width / 2; return [x1 - x2, 0]; }, translateY: function(t, i){ var docScrolls={ top: document.body.scrollTop + document.documentElement.scrollTop }, y1=window.innerHeight + docScrolls.top, tBounds=t.getBoundingClientRect(), y2=tBounds.top + docScrolls.top + tBounds.height / 2; return [y1 - y2, 0]; }, rotate:function(t, i){ var x1=window.innerWidth / 2, tBounds=t.getBoundingClientRect(), x2=tBounds.left + tBounds.width / 2; return [x2 < x1 ? 90:- 90, 0]; }, scale:[0, 1] }}, 'Ptah':{ itemOverflowHidden: true, sortTargetsFn:function(a, b){ return b.getBoundingClientRect().left - a.getBoundingClientRect().left; }, origin:'100% 0%', animeOpts:{ duration: 500, easing:'easeOutExpo', delay:function(t, i){ return i * 20; }, opacity:{ value:[0, 1], duration: 400, easing:'linear' }, rotateZ:[45, 0] }}, 'Bes':{ revealer:true, revealerOrigin:'100% 50%', animeRevealerOpts: { duration: 800, delay:function(t, i){ return i * 75; }, easing:'easeInOutQuart', scaleX:[1, 0] }, animeOpts:{ duration: 800, easing:'easeInOutQuart', delay:function(t, i){ return i * 75; }, opacity:{ value:[0, 1], easing: 'linear' }, scale:[0.8, 1] }}, 'Seker':{ revealer:true, revealerOrigin:'50% 100%', animeRevealerOpts: { duration:500, delay:function(t, i){ return i * 50; }, easing:[0.7, 0, 0.3, 1], translateY: [100, 0], scaleY:[1, 0] }, animeOpts:{ duration:500, easing:[0.7, 0, 0.3, 1], delay:function(t, i){ return i * 50; }, opacity:{ value:[0, 1], duration: 400, easing:'linear' }, translateY: [100, 0], scale:[0.8, 1] }}, 'Nut':{ revealer:true, revealerColor:'#ffffff', itemOverflowHidden: true, animeRevealerOpts:{ easing:'easeOutCubic', delay:function(t, i){ return i * 100; }, translateX: [{ value:['101%', '0%'], duration: 400 }, { value:['0%', '-101%'], duration: 400 }] }, animeOpts:{ duration: 900, easing:'easeOutCubic', delay:function(t, i){ return 400 + i * 100; }, opacity:{ value:1, duration: 1, easing:'linear' }, scale:[0.8, 1] }}, 'Shu':{ lineDrawing:true, animeLineDrawingOpts: { duration:800, delay:function(t, i){ return i * 150; }, easing:'easeInOutSine', strokeDashoffset: [anime.setDashoffset, 0], opacity:[{ value: [0, 1] }, { value:[1, 0], duration: 200, easing:'linear', delay:500 }] }, animeOpts:{ duration: 800, easing:[0.2, 1, 0.3, 1], delay:function(t, i){ return i * 150 + 800; }, opacity:{ value:[0, 1], easing: 'linear' }, scale:[0.5, 1] }} }; GridLoaderFx.prototype._render=function(effect, callback){ this._resetStyles(); var effectSettings=this.effects[effect], animeOpts=effectSettings.animeOpts if(effectSettings.perspective!=undefined){ [].slice.call(this.items).forEach(function(item){ item.style.WebkitPerspective=item.style.perspective=effectSettings.perspective + 'px'; }); } if(effectSettings.origin!=undefined){ [].slice.call(this.items).forEach(function(item){ item.style.WebkitTransformOrigin=item.style.transformOrigin=effectSettings.origin; }); } if(effectSettings.lineDrawing!=undefined){ [].slice.call(this.items).forEach(function(item){ var svg=document.createElementNS('http://www.w3.org/2000/svg', 'svg'), path=document.createElementNS('http://www.w3.org/2000/svg', 'path'), itemW=item.offsetWidth, itemH=item.offsetHeight; svg.setAttribute('width', itemW + 'px'); svg.setAttribute('height', itemH + 'px'); svg.setAttribute('viewBox', '0 0 ' + itemW + ' ' + itemH); svg.setAttribute('class', 'grid__deco'); path.setAttribute('d', 'M0,0 l' + itemW + ',0 0,' + itemH + ' -' + itemW + ',0 0,-' + itemH); path.setAttribute('stroke-dashoffset', anime.setDashoffset(path)); svg.appendChild(path); item.appendChild(svg); }); var animeLineDrawingOpts=effectSettings.animeLineDrawingOpts; animeLineDrawingOpts.targets=this.el.querySelectorAll('.grid__deco > path'); anime.remove(animeLineDrawingOpts.targets); anime(animeLineDrawingOpts); } if(effectSettings.revealer!=undefined){ [].slice.call(this.items).forEach(function(item){ var revealer=document.createElement('div'); revealer.className='grid__reveal'; if(effectSettings.revealerOrigin!=undefined){ revealer.style.transformOrigin=effectSettings.revealerOrigin; } if(effectSettings.revealerColor!=undefined){ revealer.style.backgroundColor=effectSettings.revealerColor; } item.appendChild(revealer); }); var animeRevealerOpts=effectSettings.animeRevealerOpts; animeRevealerOpts.targets=this.el.querySelectorAll('.grid__reveal'); animeRevealerOpts.begin=function(obj){ for(var i=0, len=obj.animatables.length; i < len; ++ i){ obj.animatables[i].target.style.opacity=1; }}; anime.remove(animeRevealerOpts.targets); anime(animeRevealerOpts); } if(effectSettings.itemOverflowHidden){ [].slice.call(this.items).forEach(function(item){ item.style.overflow='hidden'; }); } animeOpts.targets = effectSettings.sortTargetsFn&&typeof effectSettings.sortTargetsFn==='function' ? [].slice.call(this.items) .sort(effectSettings.sortTargetsFn):this.items; if(typeof callback!=='undefined'){ animeOpts.complete=callback; } anime.remove(animeOpts.targets); anime(animeOpts); }; GridLoaderFx.prototype._resetStyles=function(){ this.el.style.WebkitPerspective=this.el.style.perspective='none'; [].slice.call(this.items).forEach(function(item){ var gItem=item; item.style.opacity=0; item.style.WebkitTransformOrigin=item.style.transformOrigin='50% 50%'; item.style.transform='none'; var svg=item.querySelector('svg.grid__deco'); if(svg){ gItem.removeChild(svg); } var revealer=item.querySelector('.grid__reveal'); if(revealer){ gItem.removeChild(revealer); } gItem.style.overflow=''; }); }; window.GridLoaderFx=GridLoaderFx; } )(window); !function(n){var r=/([^&=]+)=?([^&]*)/g,e=/\+/g,t=function(n){return decodeURIComponent(n.replace(e," "))};n.parseParams=function(n){for(var e,u={};e=r.exec(n);){var a=t(e[1]),o=t(e[2]);"[]"===a.substring(a.length-2)?(a=a.substring(0,a.length-2),(u[a]||(u[a]=[])).push(o)):u[a]=o}return u}}(jQuery); ( function($){ "use strict"; learts.closeTopBar=function(){ var $closeBtn=$('.topbar-close-btn'), $openBtn=$('.topbar-open-btn'), $topBar=$('.topbar'), height=$topBar.outerHeight(); $closeBtn.on('click', function(e){ e.preventDefault(); if(! $topBar.hasClass('closed')){ $topBar.addClass('closed'); $('#page-container').css('margin-top', 0 - height); }}); $openBtn.on('click', function(e){ e.preventDefault(); if($topBar.hasClass('closed')){ $topBar.removeClass('closed'); $('#page-container').css('margin-top', 0); }}); }} )(jQuery); ( function($){ "use strict"; learts.switcher=function(){ var $body=$('body'), $languageSwitcher=$('.language-switcher select'), $currencySwitcher=$('.currency-switcher select'), $WOOCSCurrencySwitcher=$('.currency-switcher.woocs-switcher'), $WPMLCurrencySwitcher=$('.currency-switcher.wcml-switcher'); var loadCurrency=function(currency){ $.ajax({ type:'post', url:leartsConfigs.ajax_url, data:{ action:'wcml_switch_currency', currency: currency, }, success: function(){ window.location=window.location.href; }, error:function(error){ console.log(error); }, }); }; var WOOCSSwitcher=function(){ $('.option', $WOOCSCurrencySwitcher).on('click', function(){ $WPMLCurrencySwitcher.addClass('loading'); var $this=$(this); $('.currency-switcher').addClass('loading'); setTimeout(function(){ window.location=$this.attr('data-value'); }, 500); }); }; var wooWPMLSwitcher=function(){ $('.option', $WPMLCurrencySwitcher).on('click', function(){ $WPMLCurrencySwitcher.addClass('loading'); var currency=$(this).find('.option').attr('data-value'); loadCurrency(currency); }); }; $languageSwitcher.each(function(){ var $this=$(this); if($('option', $this).length){ $this.niceSelect(); var $niceSelect=$this.parent().find('.nice-select'), imgSrc=$this.find(':selected').attr('data-imagesrc'); if(typeof imgSrc!='undefined'){ $niceSelect.find('span.current').prepend('image'); } $this.find('option').each(function(){ imgSrc=$(this).attr('data-imagesrc'); var index=$(this).index(); if(typeof imgSrc!='undefined'){ $niceSelect.find('.option') .eq(index) .prepend('image'); }}); $body.on('click', '.language-switcher .nice-select .option', function(){ var $this=$(this); $('.language-switcher').addClass('loading'); setTimeout(function(){ window.location=$this.attr('data-value'); }, 500); }); }}); if($('option', $currencySwitcher).length){ $currencySwitcher.niceSelect(); WOOCSSwitcher(); wooWPMLSwitcher(); }};} )(jQuery); (function($){ "use strict"; learts.offcanvas=function(){ var $body=$('body'), $sidebar=$('.offcanvas-sidebar'), $offCanvasMenu=$('.offcanvas-menu'), $offCanvasButton=$('.offcanvas-btn > a'), $offCanvasClose=$('.offcanvas-close'), $pageContainer=$('#page-container'); if($offCanvasButton==null){ return; } var offcanvasSidebar=function(){ $offCanvasButton.on('click', function(e){ e.preventDefault(); $sidebar.addClass('open'); $body.addClass('offcanvas-sidebar-opened'); learts.setTopValue($sidebar); }); var closeSidebar=function(){ if($sidebar.hasClass('open')&&$body.hasClass('offcanvas-sidebar-opened')){ $sidebar.removeClass('open'); $body.removeClass('offcanvas-sidebar-opened'); }}; $offCanvasClose.on('click', function(e){ e.preventDefault(); closeSidebar(); }); $pageContainer.on('click', function(e){ if(! $(e.target).closest('.offcanvas-btn').length&&! $(e.target) .closest('.offcanvas-close a').length&&$sidebar.hasClass('open')){ e.preventDefault(); closeSidebar(); }}); $sidebar.find('.offcanvas-sidebar-inner').perfectScrollbar({ suppressScrollX: true }); } var fullscreenMenu=function(){ var interval=.5; $offCanvasMenu.find('.menu > li').each(function(){ $(this).css('transition-delay', interval + 's'); interval +=.1; }); $offCanvasButton.on('click', function(e){ e.preventDefault(); $offCanvasMenu.addClass('open'); $body.addClass('offcanvas-menu-opened'); learts.setTopValue($sidebar); }); var closeMenu=function(){ var $menu=$offCanvasMenu.find('.offcanvas-menu-wrapper .menu'); if($offCanvasMenu.hasClass('open')&&$body.hasClass('offcanvas-menu-opened')){ $menu.fadeOut(function(){ $body.removeClass('offcanvas-menu-opened'); $menu.fadeIn(); }); }}; $offCanvasClose.on('click', function(e){ e.preventDefault(); closeMenu(); }); $pageContainer.on('click', function(e){ if(! $(e.target).closest('.offcanvas-btn').length&&! $(e.target) .closest('.offcanvas-close a').length&&$sidebar.hasClass('open')){ e.preventDefault(); closeMenu(); }}); } if($sidebar.length){ offcanvasSidebar(); } if($offCanvasMenu.length){ fullscreenMenu(); }} })(jQuery); (function($){ "use strict"; var $window=$(window); learts.stickyHeader=function(){ if(! leartsConfigs.sticky_header){ return; } var $header=$('.site-header'), $topBar=$('.topbar'); if(! $header.length){ return; } if($header.hasClass('header-vertical')&&$window.width() >=1200){ return; } var $leftCol=$header.find('.left-col'), $logo=$header.find('.site-logo'), $menu=$header.find('.site-menu'), $tools=$header.find('.header-tools'), $search=$header.find('.header-search'), $offCanvaBtn=$header.find('.offcanvas-btn'); var stickyHeaderHTML=''; $header.before(stickyHeaderHTML); var $stickyHeader=$('.sticky-header'); if($logo.length){ var $img=$stickyHeader.find('.site-logo img'); if($img.length){ var o_logo=$img.attr('data-o_logo'); if(typeof o_logo!=undefined){ $img.attr('src', o_logo); }} } $window.scroll(function(){ var offset=$header.outerHeight(), currentScroll=$(this).scrollTop(), $realLeftCol=$('.site-header:not(.sticky-header)').find('.left-col'), $realMenu=$('.site-header:not(.sticky-header)').find('.site-menu'), $realTools=$('.site-header:not(.sticky-header)').find('.header-tools'), $stickyLeftCol=$stickyHeader.find('.left-col'), $stickyMenu=$stickyHeader.find('.site-menu'), $stickyTools=$stickyHeader.find('.header-tools'); if($topBar.length){ offset +=$topBar.outerHeight(); } if($('#wpadminbar').length){ offset +=$('#wpadminbar').outerHeight(); } if(currentScroll > offset - 10){ $stickyHeader.addClass('is-sticky'); $header.addClass('real-header'); $('.site-header.real-header').css('height', $header.outerHeight()); $realTools.find('>div').appendTo('.site-header.sticky-header .header-tools'); if($header.hasClass('header-menu-bottom')){ if($stickyTools.hasClass('layout-only-mini-cart')){ $search.prependTo($stickyTools); } if($offCanvaBtn.hasClass('on-left')){ $offCanvaBtn.appendTo('.site-header.sticky-header .left-col'); }else{ $offCanvaBtn.appendTo($stickyTools); }}else{ $realLeftCol.find('>div').appendTo('.site-header.sticky-header .left-col'); if($header.hasClass('header-base')&&$offCanvaBtn.hasClass('on-left')){ $offCanvaBtn.find('>a').appendTo('.site-header.sticky-header .offcanvas-btn'); }} if(! $header.hasClass('header-menu-left')){ $realMenu.find('>div').appendTo('.site-header.sticky-header .site-menu'); }}else{ $stickyLeftCol.find('>div').appendTo('.site-header.real-header .left-col'); $stickyMenu.find('>div').appendTo('.site-header.real-header .site-menu'); $stickyTools.find('>div').appendTo('.site-header.real-header .header-tools'); if($header.hasClass('header-menu-bottom')){ if($stickyTools.hasClass('layout-only-mini-cart')){ $search.appendTo('.site-header.real-header .site-menu'); } if($offCanvaBtn.hasClass('on-left')){ $offCanvaBtn.prependTo('.site-header.real-header .site-menu-wrap > .container'); }else{ $offCanvaBtn.appendTo('.site-header.real-header .site-menu-wrap > .container'); }}else{ if($header.hasClass('header-base')&&$offCanvaBtn.hasClass('on-left')){ $stickyHeader.find('.offcanvas-btn > a') .appendTo('.site-header.real-header .offcanvas-btn'); }} $('.site-header.real-header').css('height', 'auto'); $stickyHeader.removeClass('is-sticky'); $header.removeClass('real-header'); } learts.setTopValue($('.header-minicart').find('.minicart-dropdown-wrapper')); learts.setTopValue($('.header-wishlist').find('.wishlist-dropdown-wrapper')); }); $window.scroll(); }; learts.splitNavHeader=function(){ var $header=$('.header-split'); if(! $header.length){ return; } var $navigation=$header.find('.site-menu'), $navItems=$navigation.find('.menu > li'), itemsNumber=$navItems.length, rtl=$('body').hasClass('rtl'), midIndex=parseInt(itemsNumber / 2 + .5 * rtl - .5), $midItem=$navItems.eq(midIndex), $logo=$header.find('.site-logo > a'), logoWidth, leftWidth=0, rule=rtl ? 'marginLeft':'marginRight', rightWidth=0; var recalc=function(){ logoWidth=$logo.outerWidth(), leftWidth=0, rightWidth=0; for(var i=itemsNumber - 1; i >=0; i --){ var itemWidth=$navItems.eq(i).outerWidth(); if(i > midIndex){ rightWidth +=itemWidth; }else{ leftWidth +=itemWidth; }} var diff=leftWidth - rightWidth; if(rtl){ if(leftWidth > rightWidth){ $navigation.find('.menu > li:first-child').css('marginRight', - diff); }else{ $navigation.find('.menu > li:last-child').css('marginLeft', diff); }}else{ if(leftWidth > rightWidth){ $navigation.find('.menu > li:last-child').css('marginRight', diff); }else{ $navigation.find('.menu > li:first-child').css('marginLeft', - diff); }} $midItem.css(rule, logoWidth + 25); }; $logo.imagesLoaded(function(){ recalc(); $navigation.addClass('menu-calculated'); }); $(window).on('resize', recalc); } learts.headerOverlap=function(){ if($('body').hasClass('header-overlap')){ var $header=$('.site-header:not(.sticky-header)'), $logo=$header.find('.site-logo'), $img=$logo.find('img.logo-desktop'), o_logo='', o_src=''; if($img.length){ o_logo=$img.attr('data-o_logo'); o_src=$img.attr('src'); } $header.on('mouseenter', function(){ if(o_logo){ $img.attr('src', o_logo); }}).on('mouseleave', function(){ if(o_src){ $img.attr('src', o_src); }}); }}; learts.verticalHeader=function(){ var $header=$('.site-header'); if(! $header.hasClass('header-vertical')){ return; } var toggleMenu=function(){ $('.hamburger-icon').on('click', function(){ $(this).toggleClass('is-active'); $('.site-menu').toggleClass('open'); }); $('body').on('click', '#page-container', function(e){ var $target=$(e.target).closest('.hamburger-icon'); if(! $target.length){ $('.hamburger-icon').removeClass('is-active'); $('.site-menu').removeClass('open'); }}); }; toggleMenu(); $window.on('resize', function(){ var $stickyHeader=$('.sticky-header'), $stickyLeftCol=$stickyHeader.find('.left-col'), $stickyMenu=$stickyHeader.find('.site-menu'), $stickyTools=$stickyHeader.find('.header-tools'); $stickyLeftCol.find('>div').appendTo('.site-header.real-header .left-col'); $stickyMenu.find('>div').appendTo('.site-header.real-header .site-menu'); $stickyTools.find('>div').appendTo('.site-header.real-header .header-tools'); if(! $stickyHeader.length){ learts.stickyHeader(); } if($window.width() >=1200){ $stickyHeader.remove(); }}); };})(jQuery); ( function($){ "use strict"; var $window=$(window), $body=$('body'); learts.siteMenu=function(){ var $siteHeader=$('.site-header:not(.sticky-header)'), $stickyHeader=$('.site-header.sticky-header'), $siteMenu=$siteHeader.find('.site-menu'); if($stickyHeader.hasClass('is-sticky')){ $siteMenu=$stickyHeader.find('.site-menu'); } if($siteMenu.hasClass('menu-disabled')){ return; } if(! $siteMenu.length&&! $siteMenu.find('ul.menu').length){ return; } $siteMenu.find('ul.menu').superfish({ delay:300, speed:300, speedOut:300, autoArrows:false, dropShadows:false, onBeforeShow: function(){ $(this).removeClass('animated fast fadeOutDownSmall'); $(this).addClass('animated fast fadeInUpSmall'); defaultMegaMenu($(this)); }, onShow:function(){ megaMenuOffsets($(this)); normalMenuHoverBack($(this)); }, onBeforeHide: function(){ $(this).removeClass('animated fast fadeInUpSmall'); $(this).addClass('animated fast fadeOutDownSmall'); }}); var findOffsetInCookies=function(){ $siteMenu.find('.menu-item').each(function(){ var menu_item=$(this).attr('class').match(/menu-item-\d+/g); if(menu_item&&menu_item.length==1){ menu_item=menu_item[0]; var css=Cookies.get('learts_' + menu_item); if(css){ if($(this).hasClass('mega-menu')){ $(this).find('.sub-menu').css($.parseJSON(css)); }else{ if(css=='hover-back'){ $(this).addClass('has-hover-back'); $(this).find('.sub-menu').each(function(){ $(this).addClass('hover-back'); }); }} }} }); }; var megaMenuOffsets=function($el){ if(md.mobile()||md.phone()||md.tablet()||! $el.length){ return; } wideMegaMenu($el); fullWidthMegaMenu($el); customMegaMenu($el); }; var defaultMegaMenu=function($el){ if($body.hasClass('error404')){ return; } if(! $el.length||! $el.parent().hasClass('mega-menu-default')){ return; } $siteMenu=$el.closest('.site-menu'); var mainContainerRect=$body.hasClass('single-product') ? $('.site-content > .product > .container')[0].getBoundingClientRect():$('.main-container > .container')[0] .getBoundingClientRect(), menuContainerRect=$siteMenu[0].getBoundingClientRect(), w=mainContainerRect.width - 30, left=mainContainerRect.left - menuContainerRect.left + 15; if(mainContainerRect.width > 1200){ w=1170; left=(menuContainerRect.width - w) / 2; } if($siteHeader.hasClass('header-menu-left')){ left=0; } if($siteHeader.hasClass('header-menu-bottom')){ left=menuContainerRect.width / 2 - w / 2; } var css={ 'width': w + 'px', 'left':left + 'px' } $el.css(css); }; var wideMegaMenu=function($el){ if($body.hasClass('error404')){ return; } if(! $el.length||! $el.parent().hasClass('mega-menu-wide')){ return; } $siteMenu=$el.closest('.site-menu'); var pageContainerRect=$('#page-container')[0].getBoundingClientRect(), siteMenuRect=$siteMenu[0].getBoundingClientRect(), w=window.innerWidth, left=siteMenuRect.left - ( .05 * w / 2 ) - 15; if($body.hasClass('body-boxed')){ w=pageContainerRect.width; left = ( pageContainerRect.left - siteMenuRect.left ) + ( .05 * w / 2 ) + 15; }else{ left=0 - left; } w=w * .95 - 30; var css={ 'width': w + 'px', 'left':left + 'px' }; $el.css(css); }; var fullWidthMegaMenu=function($el){ if($body.hasClass('error404')){ return; } if(! $el.length||! $el.parent().hasClass('mega-menu-full-width')){ return; } $siteMenu=$el.closest('.site-menu'); var pageContainerRect=$('#page-container')[0].getBoundingClientRect(), left=$siteMenu[0].getBoundingClientRect().left, w=window.innerWidth; if($body.hasClass('body-boxed')){ left=pageContainerRect.left - left; w=pageContainerRect.width; }else{ left=0 - left; } var css={ 'width': w + 'px', 'left':left + 'px', }; $el.css(css); }; var customMegaMenu=function($el){ var subMenuRect=$el[0].getBoundingClientRect(); if(! $el.length||! $el.parent().hasClass('mega-menu-custom')){ return; } if(isOutSide($el)){ var pageContainerRect=$('#page-container')[0].getBoundingClientRect(), sub=subMenuRect.right - pageContainerRect.right, left=0 - sub - 15, css={ 'left': left + 'px' }; $el.css(css); saveCSSToCookie($el, css); }}; var isOutSide=function($el){ if(! $el.length){ return; } var subMenuRect=$el[0].getBoundingClientRect(), screenWidth=$window.width(), viewportWidth=$body.hasClass('body-boxed') ? $('#page-container') [0].getBoundingClientRect().right:screenWidth; return subMenuRect.right >=viewportWidth; }; var hoverBack=function($el){ if(isOutSide($el)){ var cookieName=$el.parent().attr('class').match(/menu-item-\d+/g); if(! $el.hasClass('hover-back')){ $el.parent().addClass('has-hover-back'); $el.addClass('hover-back'); $el.find('.sub-menu').each(function($item){ $item.addClass('hover-back'); }); if(cookieName&&cookieName.length==1){ cookieName=cookieName[0]; Cookies.set('learts_' + cookieName, 'hover-back', { expires: 1, path:'/' }) }}else{ $el.parent().removeClass('has-hover-back'); $el.removeClass('hover-back'); $el.find('.sub-menu').each(function($item){ $item.removeClass('hover-back'); }); if(cookieName.length==1){ cookieName=cookieName[0]; Cookies.remove('learts_' + cookieName, { path: '' }); }} }}; var normalMenuHoverBack=function($el){ if(md.mobile()||md.phone()||md.tablet()||! $el.length||$el.parent() .hasClass('mega-menu')){ return; } hoverBack($el); }; var saveCSSToCookie=function($el, css){ var cookieName=$el.parent().attr('class').match(/menu-item-\d+/g); if(cookieName&&cookieName.length==1){ cookieName=cookieName[0]; Cookies.set('learts_' + cookieName, css, { expires: 1, path:'/' }) }}; findOffsetInCookies(); $window.on('resize', function(){ $siteMenu.find('.menu-item.mega-menu .sub-menu').each(function(){ defaultMegaMenu($(this)); wideMegaMenu($(this)); fullWidthMegaMenu($(this)); }); }); }; learts.setTopValue=function($el){ var $adminBar=$('#wpadminbar'), w=$window.width(), h=$adminBar.height(), top=h; if($adminBar.length){ var t=$adminBar[0].getBoundingClientRect().top; top = ( t >=0 - h ) ? h + t:0; } if($el.closest('.sticky-header.is-sticky').length){ top=0; } $el.css('top', top); }; learts.mobileMenu=function(){ var $mobileBtn=$('.mobile-menu-btn'), $mobileMenu=$('#site-mobile-menu'), $mobileMenuClz=$('.site-mobile-menu'), $pageContainer=$('#page-container'); var caculateRealHeight=function($ul){ var height=0; $ul.find('>li').each(function(){ height +=$(this).outerHeight(); }); return height; }; var setUpOverflow=function(h1, h2){ if(h1 < h2){ $mobileMenuClz.css('overflow-y', 'hidden'); }else{ $mobileMenuClz.css('overflow-y', 'auto'); }}; var buildSlideOut=function(){ if(typeof $mobileMenu!=='undefined'&&typeof $pageContainer!=='undefined'){ $body.on('click', '.mobile-menu-btn', function(){ $(this).toggleClass('is-active'); $body.toggleClass('mobile-menu-opened'); learts.setTopValue($mobileMenuClz); }); $pageContainer.on('click touchstart', function(e){ if(! $(e.target).closest('.mobile-menu-btn').length){ if($body.hasClass('mobile-menu-opened')){ $body.removeClass('mobile-menu-opened'); $mobileBtn.removeClass('is-active'); $mobileMenu.find('#searchform input[type="text"]').blur(); e.preventDefault(); }} }); setUpOverflow($mobileMenu.height(), $mobileMenuClz.height()); }}; var buildDrillDown=function(){ var level=0, opener='open', height=$mobileMenuClz.height(); $mobileMenu.find('li:has(ul)').each(function(){ var $this=$(this), allLink=$this.find('> a').clone(); if(allLink.length){ $this.prepend(opener); allLink.find('.menu-item-tag').remove(); $this.find('> ul') .prepend(''); }}); $mobileMenu.on('click', '.open-child', function(){ var $parent=$(this).parent(); if($parent.hasClass('over')){ $parent.removeClass('over'); level --; if(level==0){ setUpOverflow($mobileMenu.height(), height); }}else{ $parent.parent().find('>li.over').removeClass('over'); $parent.addClass('over'); level ++; setUpOverflow(caculateRealHeight($parent.find('>.sub-menu')), height); } $mobileMenu.parent().scrollTop(0); }); $mobileMenu.on('click', '.menu-back', function(){ var $grand=$(this).parent().parent(); if($grand.hasClass('over')){ $grand.removeClass('over'); level --; if(level==0){ setUpOverflow($mobileMenu.height(), height); }} $mobileMenu.parent().scrollTop(0); }); }; buildSlideOut(); buildDrillDown(); $window.on('resize', function(){ learts.setTopValue($mobileMenuClz); }); }; learts.menuVertical=function(){ var $menu=$('#menu-full-screen-menu'); $menu.on('click', '.menu-item-has-children > a', function(e){ e.preventDefault(); e.stopPropagation(); var $_li=$(this).parent('li'); if($_li.hasClass('opened')){ $_li.removeClass('opened'); $_li.find('.opened').removeClass('opened'); $_li.find('.sub-menu').stop().slideUp(); }else{ var $_parent=$_li.parent('ul'); if(! $_parent.hasClass('sub-menu')){ var $li_opened=$_li.siblings('.opened'); $li_opened.removeClass('opened'); $li_opened.find('.opened').removeClass('opened'); $li_opened.find('.sub-menu').stop().slideUp(); } $_li.addClass('opened'); $_li.children('.sub-menu').stop().slideDown(); }}); } learts.menuGrid=function(){ $.fn.visible=function(partial){ var $t=$(this), $w=$(window), viewTop=$w.scrollTop(), viewBottom=viewTop + $w.height(), _top=$t.offset().top, _bottom=_top + $t.height(), compareTop=partial===true ? _bottom:_top, compareBottom=partial===true ? _top:_bottom; return ((compareBottom <=viewBottom)&&(compareTop >=viewTop)); }; var win=$(window); var allMods=$('.learts-menu-grid').find('.menu-item'); allMods.each(function(i, el){ var el=$(el); if(el.visible(true)){ el.addClass('already-visible'); }}); win.scroll(function(event){ allMods.each(function(i, el){ var el=$(el); if(el.visible(true)){ el.addClass('come-in'); }}); }); }} )(jQuery); ( function($){ "use strict"; var $window=$(window), $document=$(document), body=document.body; learts.imageCarousel=function(){ $('.learts-image-carousel').each(function(){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts===null){ return; } if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ accessibility:false, slidesToShow:3, slidesToScroll: 3, infinite:( atts.loop==='yes' ), autoplay:( atts.auto_play==='yes' ), autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, adaptiveHeight: true, speed:1000, centerMode:true, variableWidth: true, responsive:[{ breakpoint: 992, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ arrows:true, dots:false, slidesToShow:1, slidesToScroll: 1, centerMode:false, }, },], }; if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type==='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type==='both'){ configs.arrows=true; configs.dots=true; }} $(this).find('.image-items').slick(configs); $(this).find('.image-items').slick('setPosition'); }); }; learts.testimonialCarousel=function(){ $('.learts-testimonial-carousel').each(function(){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts===null){ return; } if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ accessibility:false, infinite:( atts.loop=='yes' ), autoplay:( atts.auto_play=='yes' ), autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, slidesToShow:parseInt(atts.items_to_show), slidesToScroll: 1, speed:1000, responsive:[{ breakpoint: 768, settings:{ slidesToShow: 1, }, },], }; if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $this.slick(configs); }); }; learts.instagramCarousel=function(){ var carousels=[].slice.call(document.querySelectorAll('.learts-instagram--carousel')); carousels.forEach(function(carousel){ var atts=JSON.parse(carousel.getAttribute('data-atts')); if(atts==null){ return; } if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ accessibility:false, infinite:( atts.loop=='yes' ), autoplay:( atts.auto_play=='yes' ), autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, slidesToShow:parseInt(atts.number_of_items_to_show), slidesToScroll: parseInt(atts.number_of_items_to_show), speed:1000, responsive:[{ breakpoint: 768, settings:{ slidesToShow:2, slidesToScroll: 2 }, }, { breakpoint: 425, settings:{ slidesToShow:1, slidesToScroll: 1 }, },], } if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $(carousel.querySelectorAll('.tm-instagram-pics')).slick(configs); }); }; learts.countdown=function(){ var equalWidthForCountdown=function(){ if(! md.mobile()&&! md.phone()&&! md.tablet()){ $('.tm-countdown, .product-countdown').each(function(){ var max_width=0; $(this).find('.countdown-section').each(function(){ var width=$(this).outerWidth(); if(width > max_width){ max_width=width; }}); $(this).find('.countdown-section').css('width', max_width); }); }}; $('.learts-countdown').each(function(){ var $this=$(this), format=$this.attr('data-countdown-format'), text_singular=$this.attr('data-label-singular').split(','), text_plural=$this.attr('data-label-plural').split(','), date=new Date($this.text().trim()), server_date=new Date($this.attr('data-server-date')); if($this.is('.user-timezone')){ $this.countdown({ labels:text_plural, labels1: text_singular, format:format, until:date, onTick:function(){ equalWidthForCountdown(); }, }); }else{ $this.countdown({ labels:text_plural, labels1:text_singular, format:format, until:date, serverSync: server_date, onTick:function(){ equalWidthForCountdown(); }, }); }}); }; learts.productCategoriesShortcode=function(){ $('.learts-product-categories.categories-layout-carousel').each(function(){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')), number=parseInt(atts.number_of_items_to_show); if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5000; } var configs={ accessibility:false, slidesToShow:number, infinite:atts.loop=='yes', autoplay:atts.auto_play=='yes', autoplaySpeed:parseInt(atts.auto_play_speed * 1000), centerMode:atts.center_mode=='yes', centerPadding:atts.center_padding, adaptiveHeight: true, speed:1000, responsive:[{ breakpoint: 1199, settings:{ centerPadding: '100px', }, }, { breakpoint: 992, settings:{ slidesToShow:number - 1, slidesToScroll: number, centerPadding:'80px', }, }, { breakpoint: 768, settings:{ slidesToShow:( number > 2 ) ? number - 2:2, slidesToScroll: 1, centerPadding:'50px', }, }, { breakpoint: 479, settings:{ adaptiveHeight: true, arrows:true, dots:false, slidesToShow:1, centerPadding:'0px', }, },], }; if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $this.slick(configs); $this.slick('setPosition'); }); if(typeof( $.fn.isotope )=='undefined'||typeof ( $.fn.imagesLoaded )=='undefined'){ return; } var $catsContainer=$('.learts-product-categories.categories-layout-masonry'); $catsContainer.isotope({ masonry:{ columnWidth: '.col-xl-3.category-grid-item', }, itemSelector: '.category-grid-item', }).imagesLoaded().progress(function(){ $catsContainer.isotope('layout'); }) }; learts.productsShortCode=function(){ var productGrid=function(){ if(typeof( $.fn.isotope )=='undefined'||typeof( $.fn.imagesLoaded )=='undefined'){ return; } $('.learts-product-grid').each(function(){ var $this=$(this), $products=$this.find('.products'), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } $products.isotope({ layoutMode:'fitRows', itemSelector: '.product' }); $products.imagesLoaded().progress(function(){ $products.isotope('layout'); }); }); }; var productTabs=function(){ if(typeof( $.fn.isotope )=='undefined'||typeof( $.fn.imagesLoaded )=='undefined'){ return; } $('.learts-product-tabs').each(function(){ var $this=$(this), $products=$this.find('.products'), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } $products.isotope({ layoutMode:'fitRows', itemSelector:'.product', hiddenStyle:{ opacity: 0 }, visibleStyle:{ opacity: 1 }, transitionDuration: '0.5s' }); $products.imagesLoaded().progress(function(){ $products.isotope('layout'); }); }); $('.product-filter>li>a.active').each(function(){ var $this=$(this), $parent=$this.parents('.learts-product-tabs'), active_filter=$this.data('filter'); $parent.find('.learts-loadmore-wrap').attr('data-filter', active_filter); }); $('.learts-product-tabs').on('click', '.product-filter a', function(e){ e.preventDefault(); var t=$(this), r=t.data('category'), f=t.data('filter'), u=t.parents('.learts-product-tabs'); u.find('.learts-loadmore-wrap').attr('data-filter', f); if(r){ u.find('.learts-loadmore-wrap').attr('data-filter', r); } u.find('.learts-loadmore-wrap').removeClass('hidden'); var $link=$(this), $grid=$link.closest('.learts-product-tabs'), $products=$grid.find('.products'), filterValue=$link.attr('data-filter'), prependProducts=function($newProducts){ var iso=$products.data('isotope'); $products.prepend($newProducts); $products.imagesLoaded(function(){ var $items=$products.find('.adding-item'), gridFx=new GridLoaderFx($products[0], '.adding-item'); if(iso!=null){ $products.isotope('prepended', $items); } gridFx._render('Amun'); $items.removeClass('adding-item'); }); }; if($link.hasClass('active')){ return false; } var $ul=$link.closest('.product-filter'), oldFilterValue=$ul.find('.active').attr('data-filter'); $ul.find('.active').removeClass('active'); $link.addClass('active'); if($grid.hasClass('filter-type-filter')){ var filterClass=filterValue; if('*'!==filterValue){ filterClass='.product_cat-' + filterClass; } $products.isotope({ filter: filterClass }); }else{ filterValue=filterValue.replace(/\./g, ''); filterValue=filterValue.replace(/product_cat-/g, ''); oldFilterValue=oldFilterValue.replace(/\./g, ''); oldFilterValue=oldFilterValue.replace(/product_cat-/g, ''); var oldItem=$grid.attr('id') + '_' + oldFilterValue, cache=sessionStorage.getItem($grid.attr('id') + '_' + filterValue); if(! sessionStorage.getItem(oldItem)){ $products.children('.product').addClass('adding-item'); sessionStorage.setItem(oldItem, $products.html()); } var data_btn=u.find('.learts-loadmore-wrap').attr('data-atts'); console.log(data_btn); if(data_btn){ var atts_btn=JSON.parse(data_btn); var next_page=$link.attr('data-page'); atts_btn.paged=next_page; atts_btn=JSON.stringify(atts_btn); u.find('.learts-loadmore-wrap').attr('data-atts', atts_btn); }else{ next_page=1; } var atts=JSON.parse($grid.attr('data-atts')); if(atts==null){ return; } var data={ action:'learts_ajax_load_more', post_type:'product', posts_per_page: atts.number * next_page, columns:atts.columns, data_source:atts.data_source }; if(atts.filter=='category'){ data.category=filterValue; data.include_children=atts.include_children=='yes'; } if(atts.filter=='group'){ data.data_source=filterValue; } $.ajax({ method:'POST', url:leartsConfigs.ajax_url, data:data, cache:true, beforeSend: function(){ $products.addClass('loading'); }, success:function(response){ if(response){ $products.children('.product').remove(); prependProducts($(response)); } $products.removeClass('loading'); }, error:function(error){ console.log(error); }}); }}); }; var productCarousel=function(){ $('.learts-product-carousel').each(function(){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ accessibility:false, slidesToShow:parseInt(atts.columns), slidesToScroll: parseInt(atts.columns), speed:1000, infinite:( atts.loop==='yes' ), autoplay:( atts.auto_play==='yes' ), autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, responsive:[{ breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, }, }, { breakpoint: 768, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 425, settings:{ adaptiveHeight: true, arrows:true, dots:false, centerMode:true, centerPadding:'50px', slidesToShow:1, slidesToScroll: 1, }, }, { breakpoint: 375, settings:{ adaptiveHeight: true, arrows:true, dots:false, centerMode:true, centerPadding:'30px', slidesToShow:1, slidesToScroll: 1, }, },], }; if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $this.find('.products').slick(configs); }); }; var productWidget=function(){ $('.learts-product-widget') .find('.hint--left') .removeClass('hint--left') .addClass('hint--top'); $('.learts-product-widget') .find('.hint--top-left') .removeClass('hint--top-left') .addClass('hint--top'); $('.learts-product-widget').each(function(){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } var enable_carousel=atts.enable_carousel==='yes'; if(enable_carousel){ var $products=$this.find('.product_list_widget'); if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ accessibility:false, slidesToShow:1, slidesToScroll: 1, speed:1000, autoplay:atts.auto_play==='yes', autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, }; if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=atts.arrows_position=='left-right'; configs.dots=true; } if(atts.nav_type=='arrows'){ configs.arrows=atts.arrows_position=='left-right'; }} $products.slick(configs); $this.find('.slick-prev.small').on('click', function(){ $products.slick('slickPrev'); }); $this.find('.slick-next.small').on('click', function(){ $products.slick('slickNext'); }); }}); }; productGrid(); productTabs(); productCarousel(); productWidget(); }; learts.vcTabs=function(){ $('.vc_tta-panel').each(function(){ var $this=$(this), $carousel=$this.find('.slick-slider'); $document.on('beforeShow.vc.accordion', function(){ $this.find('.product').addClass('animated'); }); $document.on('afterShow.vc.accordion', function(){ $window.trigger('resize'); setTimeout(function(){ $this.find('.product').removeClass('zoomOut').addClass('zoomIn'); }, 500); }); if($carousel.length&&$carousel.find('.slick-arrow').length){ $document.on('beforeShow.vc.accordion', function(){ $carousel.find('.slick-track').addClass('filtering').css('opacity', 0); }); $document.on('afterShow.vc.accordion', function(){ var $panelBody=$carousel.closest('.vc_tta-panel-body'); $panelBody.css('overflow', 'initial'); $carousel.slick('setPosition'); $carousel.find('.slick-track').removeClass('filtering').css('opacity', 1); }); }}); }; learts.vcRow=function(){ var init=function(){ var rows=[].slice.call(document.querySelectorAll('.vc_row.vc_row-learts-wide')), siteContent=document.getElementsByClassName('site-content'); rows.forEach(function(row){ if(window.innerWidth < 992){ row.style=''; return; } if(body.classList.contains('site-header-vertical')&&window.innerWidth >=1200){ var margin=$(body).css('margin-left'); margin=parseInt(margin.replace('px', '')); } var w=body.classList.contains('site-header-vertical') ? window.innerWidth - margin:window.innerWidth, l=siteContent[0].getBoundingClientRect().left; w=w * .95; l=- 1 * ( l - w * 0.05 / 2 ); if(row.classList.contains('vc_row-no-padding')){ w -=30; l +=15; } if(body.classList.contains('site-header-vertical')&&window.innerWidth >=1200){ l +=margin; } row.style.position='relative'; row.style.width=w + 'px'; row.style.left=l + 'px'; setTimeout(function(){ row.classList.add('row-calculated'); }, 300); setTimeout(function(){ var $products=$(row).find('.products'); if($products.data('isotope')){ $products.isotope('layout'); }}, 1000); }); }; var stretchRow=function(mode){ if(! body.classList.contains('site-header-vertical')&&window.innerWidth < 1200){ return; } var rows=[].slice.call(document.querySelectorAll('.vc_row[data-vc-stretch-content="true"]')); rows.forEach(function(row){ if(row.getAttribute('style')!=null&&! row.classList.contains('row-calculated')){ var margin=$(body).css('margin-left'); margin=parseInt(margin.replace('px', '')); var w=window.innerWidth - margin, l=parseInt(row.style.left.replace('px', '')); row.style.width=w + 'px'; row.style.left=( l + margin ) + 'px'; row.classList.add('row-calculated'); } if(mode!='resize'){ setTimeout(function(){ var $products=$(row).find('.products'); if($products.data('isotope')){ $products.isotope('layout'); }}, 1000); }}); if(mode!='resize'){ $window.trigger('resize'); }}; init(); $window.on('load', function(){ stretchRow('load'); }); $window.on('resize', function(){ init(); var rows=[].slice.call(document.querySelectorAll('.vc_row.row-calculated[data-vc-stretch-content="true"]')); rows.forEach(function(row){ row.classList.remove('row-calculated'); }); setTimeout(function(){ stretchRow('resize'); }); }); }; learts.vcColumn=function(){ var $stickyCol=$('.vc_col-learts-sticky .vc_column-inner'); if(md.mobile()||md.phone()||md.tablet()||! $stickyCol.length||$window.width() < 1200){ return; } $stickyCol.stick_in_parent(); } learts.bannerGrid5=function(){ var banners=[].slice.call(document.querySelectorAll('.learts-banner-grid-5')); banners.forEach(function(_banner){ var _items=[].slice.call(_banner.querySelectorAll('.tm-shortcode')); if(_items){ for(var i=0; i < _items.length; i +=5){ var chuck=_items.splice(i, i + 5), $chuck=$(chuck); $chuck.filter(':lt(3)').wrapAll('
'); $chuck.filter(':gt(2)').wrapAll('
'); } _banner.classList.add('banner-loaded'); }}); }; learts.bannerGrid6=function(){ var banners=[].slice.call(document.querySelectorAll('.learts-banner-grid-6')); banners.forEach(function(_banner){ var _items=[].slice.call(_banner.querySelectorAll('.tm-shortcode')); if(_items){ for(var i=0; i < _items.length; i +=6){ var chuck=_items.splice(i, i + 6), $chuck=$(chuck); $chuck.filter(':lt(3)').wrapAll('
'); $chuck.filter(':eq(3)').wrapAll('
'); $chuck.filter(':gt(3)').wrapAll('
'); } _banner.classList.add('banner-loaded'); }}); }; learts.bannerGrid6v2=function(){ var banners=[].slice.call(document.querySelectorAll('.learts-banner-grid-6v2')); banners.forEach(function(_banner){ var _items=[].slice.call(_banner.querySelectorAll('.tm-shortcode')); if(_items){ for(var i=0; i < _items.length; i +=6){ var chuck=_items.splice(i, i + 6), $chuck=$(chuck); $chuck.wrapAll('
'); $chuck.filter(':lt(2)').wrapAll('
'); $chuck.filter(':gt(1)').wrapAll('
'); } _banner.classList.add('banner-loaded'); }}); }; learts.bannerCarousel=function(){ $('.learts-banner-carousel').find('.banner-items').slick({ dots:true, speed:1000, slidesToShow:1, centerMode:true, variableWidth: true, responsive:[{ breakpoint: 768, settings:{ slidesToShow:1, slidesToScroll: 1, centerMode:false, variableWidth:false, }, }], }); }} )(jQuery); ( function($){ "use strict"; var $window=$(window); learts.backToTop=function(){ var $backToTop=$('.back-to-top'); $window.scroll(function(){ if($window.scrollTop() > 100){ $backToTop.addClass('show'); }else{ $backToTop.removeClass('show'); }}); $backToTop.on('click', function(e){ e.preventDefault(); $('html, body').animate({ scrollTop: 0 }, 600); }); } var $scroll=$('.button-scroll'); $scroll.on('click', function(){ if(this.hash!==""){ event.preventDefault(); var hash=this.hash; $('html, body').animate({ scrollTop: $(hash).offset().top }, 800, function(){ window.location.hash=hash; }); }}); } )(jQuery); ( function($){ "use strict"; learts.fitVideo=function(){ $('.container').fitVids(); }; learts.thumbGallery=function(){ var sliders=[].slice.call(document.querySelectorAll('.post-gallery > .slider')); sliders.forEach(function(slider){ if([].slice.call(slider.querySelectorAll('.single-image')).length&&! slider.classList.contains('slick-initialized')){ $(slider).slick({ accessibility:false, slidesToShow:1, arrows:true, dots:false, infinite:true, adaptiveHeight: true, }); $('.single-image:not(.slick-cloned)').magnificPopup({ delegate: 'a', gallery:{ enabled: true, }, type:'image', }); }}); }; learts.blog=function(){ var blogMasonry=function(){ if(typeof( $.fn.isotope )=='undefined'||typeof( $.fn.imagesLoaded )=='undefined'){ return; } var masonryContainers=[].slice.call(document.querySelectorAll('.masonry-container')); masonryContainers.forEach(function(container){ setTimeout(function(){ imagesLoaded(container, function(){ new Isotope(container, { gutter:0, itemSelector: '.masonry-item' }).layout(); }); container.classList.add('loaded'); new GridLoaderFx(container, '.masonry-item')._render('Amun'); }, 500); }); }; var postsSlider=function(){ var sliders=[].slice.call(document.querySelectorAll('.learts-blog .js-post-carousel')); sliders.forEach(function(slider){ var atts=JSON.parse(slider.getAttribute('data-atts')); if(atts==null){ return; } if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ slidesToShow:parseInt(atts.columns), slidesToScroll: parseInt(atts.columns), adaptiveHeight: true, infinite:( atts.loop=='yes' ), autoplay:( atts.auto_play=='yes' ), autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, prevArrow:'', nextArrow:'', responsive:[{ breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, }, }, { breakpoint: 769, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ adaptiveHeight: true, arrows:true, dots:false, centerMode:true, centerPadding:'30px', slidesToShow:1, slidesToScroll: 1, }, },], }; if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} $(slider).slick(configs); setTimeout(function(){ var thumbGalleries=[].slice.call(slider.querySelectorAll('.post-gallery > .slider')); thumbGalleries.forEach(function(gallery){ if(typeof $(gallery).get(0).slick!='undefined'){ $(gallery).get(0).slick.setPosition(); }}); }, 1000); }); }; var blogShortcode=function(){ var posts=[].slice.call(document.querySelectorAll('.learts-blog .posts')); if(! posts.length){ return; } posts.forEach(function(post){ var gridFx=new GridLoaderFx(post, '.post-item'), masonryConfig={ itemSelector: '.post-item' }; if(post.classList.contains('post-carousel-layout')){ setTimeout(function(){ post.parentNode.classList.add('loaded'); }, 500); return; }else if(post.classList.contains('post-grid-layout')){ masonryConfig.layoutMode='fitRows'; } setTimeout(function(){ imagesLoaded(post, function(){ new Isotope(post, masonryConfig).layout(); }); post.parentNode.classList.add('loaded'); gridFx._render('Seker'); }, 500); }); }; learts.fitVideo(); learts.thumbGallery(); blogMasonry(); postsSlider(); blogShortcode(); };} )(jQuery); ( function($){ "use strict"; var $body=$('body'); learts.search=function(){ var $search=$('.header-search'), $formWrapper=$('.search-form-wrapper'), $closeBtn=$('.btn-search-close'), $form=$('form.ajax-search-form'), $select=$form.find('select.search-select'), $input=$form.find('input.search-input'), $ajaxNotice=$('.ajax-search-notice'), noticeText=$ajaxNotice.text(), found=false; if(! $search.length){ return; } var categoriesSelectBox=function(){ if($select.find('>option').length){ $select.select2({ templateResult: function(str){ if(! str.id){ return str.text; } return $('' + str.text + ''); }, }).on('change', function(){ var text=$(this) .find('option[value="' + $(this).val() + '"]') .text() .trim(); $('#select2-product_cat-container').text(text); $('#select2-cat-container').text(text); setTimeout(function(){ $input.focus(); }, 500); ajaxSearch(); }); $select.next('.select2').on('mousedown', function(){ $('#select2-product_cat-results').perfectScrollbar(); }); }}; var events=function(){ $search.on('click', '> .toggle', function(e){ e.preventDefault(); openSearch(); }); $search.on('focus', 'input.fake-input', function(e){ e.preventDefault(); openSearch(); }); $closeBtn.on('click', function(){ closeSearch(); }); $input.on('keyup', function(event){ if(event.altKey||event.ctrlKey||event.shiftKey||event.metaKey){ return; } var keys=[9, 16, 17, 18, 19, 20, 33, 34, 35, 36, 37, 39, 45, 46]; if(keys.indexOf(event.keyCode)!=- 1){ return; } switch(event.which){ case 8: if($(this).val().length < leartsConfigs.search_min_chars){ $('.autocomplete-suggestion').remove(); $('.search-view-all').remove(); $ajaxNotice.fadeIn(200).text(noticeText); } break; case 27: if($(this).val()==''){ closeSearch(); } $('.autocomplete-suggestion').remove(); $('.search-view-all').remove(); $(this).val(''); $ajaxNotice.fadeIn(200).text(noticeText); break; default: break; }}); }; var ajaxSearch=function(){ var productCat='0', cat='0', symbol=leartsConfigs.ajax_url.split('?')[1] ? '&':'?', postType=$form.find('input[name="post_type"]').val(), url=leartsConfigs.ajax_url + symbol + 'action=learts_ajax_search'; if($select.find('option').length){ productCat=cat=$select.val(); } if(postType=='product'){ url +='&product_cat=' + productCat; }else{ url +='&cat=' + cat; } url +='&limit=' + leartsConfigs.search_limit; $input.devbridgeAutocomplete({ serviceUrl:url, minChars:leartsConfigs.search_min_chars, appendTo:$('.search-results-wrapper'), deferRequestBy:300, beforeRender:function(container){ container.perfectScrollbar(); }, onSelect:function(suggestion){ if(suggestion.url.length){ window.location.href=suggestion.url; } if(suggestion.id==- 2){ return; }}, onSearchStart:function(){ $formWrapper.addClass('search-loading'); }, onSearchComplete: function(query, suggestions){ $formWrapper.removeClass('search-loading'); if(found&&suggestions[0].id!=- 1){ $ajaxNotice.fadeOut(200); }else{ $ajaxNotice.fadeIn(200); } if(suggestions.length > 1&&suggestions[suggestions.length - 1].id==- 2){ var viewAll=suggestions[suggestions.length - 1]; $formWrapper.find('.autocomplete-suggestions') .append(''); } $('.autocomplete-suggestion').each(function(){ if(! $(this).html()){ $(this).remove(); }}); }, formatResult:function(suggestion, currentValue){ return generateHTML(suggestion, currentValue); }, }); }; var generateHTML=function(suggestion, currentValue){ var postType=$form.find('input[name="post_type"]').val(), pattern='(' + escapeRegExChars(currentValue) + ')', returnValue=''; if(suggestion.id==- 1){ $ajaxNotice.text(suggestion.value).fadeIn(200); return returnValue; } if(suggestion.id==- 2){ return returnValue; } found=true; if(suggestion.thumbnail){ returnValue +='
' + suggestion.thumbnail + '
'; } if(suggestion.id!=- 2){ returnValue +='
'; } var title=suggestion.value.replace(new RegExp(pattern, 'gi'), '$1<\/ins>') .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/<(\/?ins)>/g, '<$1>') + ''; if(suggestion.url.length){ returnValue +='' + title + ''; }else{ returnValue +='
' + title + '
'; } if(postType==='product'){ var sku=suggestion.sku; if(leartsConfigs.search_by=='sku'||leartsConfigs.search_by=='both'){ sku=suggestion.sku.replace(new RegExp(pattern, 'gi'), '$1<\/ins>') .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/<(\/?ins)>/g, '<$1>') + ''; } if(suggestion.sku){ returnValue +='SKU: ' + sku + ''; } if(suggestion.price){ returnValue +='' + suggestion.price + ''; }} if(postType==='post'){ if(suggestion.date){ returnValue +='' + suggestion.date + ''; }} if(suggestion.excerpt&&leartsConfigs.search_excerpt_on){ returnValue +='

' + suggestion.excerpt + '

'; } if(suggestion.id!=- 2){ returnValue +='
'; } return returnValue; }; var escapeRegExChars=function(value){ return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); }; categoriesSelectBox(); events(); ajaxSearch(); var openSearch=function(){ $body.addClass('search-opened'); $formWrapper.addClass('search--open'); $closeBtn.removeClass('btn--hidden'); setTimeout(function(){ $input.focus(); }, 500); }; var closeSearch=function(){ $body.removeClass('search-opened'); $formWrapper.removeClass('search--open'); $closeBtn.addClass('btn--hidden'); setTimeout(function(){ $input.blur(); }, 500); };}} )(jQuery); (function($){ "use strict"; var $window=$(window), $body=$('body'); learts.wishlist=function(){ var $wishlist=$('.header-wishlist'), $dropDown=$wishlist.find('.wishlist-dropdown-wrapper'), updatingWishlist=false, removeAfterAddToCart=false, undoTimeout; if(! $wishlist.length){ return; } var wlFragments=function(){ var $supports_html5_storage, wl_hash_key='learts_wl_hash', fragment_name='learts_wl_fragments'; try { $supports_html5_storage=( 'sessionStorage' in window&&window.sessionStorage!==null ); window.sessionStorage.setItem('learts', 'test'); window.sessionStorage.removeItem('learts'); window.localStorage.setItem('learts', 'test'); window.localStorage.removeItem('learts'); } catch(err){ $supports_html5_storage=false; } function set_wl_creation_timestamp(){ if($supports_html5_storage){ sessionStorage.setItem('learts_wl_created', ( new Date() ).getTime()); }} function set_wl_hash(wl_hash){ if($supports_html5_storage){ localStorage.setItem(wl_hash_key, wl_hash); sessionStorage.setItem(wl_hash_key, wl_hash); }} var $fragment_refresh={ url:leartsConfigs.ajax_url, type:'GET', data:{ action: 'learts_get_wishlist_fragments', }, success: function(data){ if(data&&data.fragments){ $.each(data.fragments, function(key, value){ $(key).replaceWith(value); }); if($supports_html5_storage){ sessionStorage.setItem(fragment_name, JSON.stringify(data.fragments)); set_wl_hash(data.wl_hash); if(data.wl_hash){ set_wl_creation_timestamp(); }} $(document.body).trigger('wl_fragments_refreshed'); }}, error:function(error){ console.log(error); }, }; function refresh_wl_fragment(){ $.ajax($fragment_refresh); } if($supports_html5_storage){ var wl_timeout=null, day_in_ms=24 * 60 * 60 * 1000; $(document.body).bind('wl_fragment_refresh updated_wc_div', function(){ refresh_wl_fragment(); }); $(document.body) .bind('added_to_wishlist removed_from_wishlist', function(event, fragments, cart_hash){ var prev_wl_hash=sessionStorage.getItem(wl_hash_key); if(prev_wl_hash===null||prev_wl_hash===undefined||prev_wl_hash===''){ set_wl_creation_timestamp(); } sessionStorage.setItem(fragment_name, JSON.stringify(fragments)); refresh_wl_fragment(); }); $(document.body).bind('wl_fragments_refreshed', function(){ clearTimeout(wl_timeout); wl_timeout=setTimeout(refresh_wl_fragment, day_in_ms); }); $window.on('storage onstorage', function(e){ if(wl_hash_key===e.originalEvent.key&&localStorage.getItem(wl_hash_key)!==sessionStorage.getItem(wl_hash_key)){ refresh_wl_fragment(); }}); try { var wl_fragments=JSON.parse(sessionStorage.getItem(fragment_name)), wl_hash=sessionStorage.getItem(wl_hash_key), cookie_hash=Cookies.set('learts_wl_hash'), wl_created=sessionStorage.getItem('learts_wl_created'); if(wl_hash===null||wl_hash===undefined||wl_hash===''){ wl_hash=''; } if(cookie_hash===null||cookie_hash===undefined||cookie_hash===''){ cookie_hash=''; } if(wl_hash&&( wl_created===null||wl_created===undefined||wl_created==='' )){ throw 'No wishlist_created'; } if(wl_created){ var wl_expiration=1 * cart_created + day_in_ms, timestamp_now=( new Date() ).getTime(); if(cart_expiration < timestamp_now){ throw 'Fragment expired'; } wl_timeout=setTimeout(refresh_wl_fragment, ( wl_expiration - timestamp_now )); } if(wl_fragments&&wl_fragments['div.widget_wishlist_content']&&wl_hash===cookie_hash){ $.each(wl_fragments, function(key, value){ $(key).replaceWith(value); }); $(document.body).trigger('wl_fragments_loaded'); }else{ throw 'No fragment'; }} catch(err){ refresh_wl_fragment(); }}else{ refresh_wl_fragment(); }}; var events=function(){ $wishlist.on('click', '>.toggle', function(e){ e.preventDefault(); if(! $wishlist.hasClass('wishlist-open')){ open(); }else{ close(); }}); $body.on('click', '#page-container', function(e){ var $target=$(e.target).closest('.header-wishlist'); if(! $target.length){ close(); }}); $body.on('added_to_wishlist wl_fragments_refreshed wl_fragments_loaded', function(){ initUndo(); initRemove(); initAddToCart(); $wishlist.find('.product_list_widget').perfectScrollbar({ suppressScrollX: true }); }); $window.on('resize', function(){ learts.setTopValue($dropDown); }); }; var open=function(){ $wishlist.addClass('wishlist-open'); $body.addClass('wishlist-opened'); $wishlist.find('.close-btn').on('click', function(e){ e.preventDefault(); close(); }); learts.setTopValue($dropDown); }; var close=function(){ $wishlist.removeClass('wishlist-open'); $body.removeClass('wishlist-opened'); }; var initRemove=function(){ $wishlist.find('.wishlist_item .remove').on('click', function(e){ e.preventDefault(); var $this=$(this), $item=$this.closest('.wishlist_item'), product_id=$item.data('product_id'), wishlistID=$item.data('wishlist_id'), wishlistToken=$item.data('wishlist_token'), data={ remove_from_wishlist: product_id, wishlist_id:wishlistID, wishlist_token:wishlistToken, }; request('remove', data, function(){ resetUndo(); $item.addClass('deleted'); if(! removeAfterAddToCart){ $wishlist.find('.undo').addClass('visible'); } var $wlButtons=$('.yith-wcwl-add-to-wishlist.add-to-wishlist-' + product_id); if($wlButtons.length){ $wlButtons.find('.yith-wcwl-add-button') .show() .removeClass('hide') .addClass('show'); $wlButtons.find('.yith-wcwl-wishlistaddedbrowse') .hide() .removeClass('show') .addClass('hide'); $wlButtons.find('.yith-wcwl-wishlistexistsbrowse') .hide() .removeClass('show') .addClass('hide'); $wlButtons.find('.add_to_wishlist').removeClass('loading'); } undoTimeout=setTimeout(function(){ resetUndo(); }, 8000); }); }); }; var initUndo=function(){ $wishlist.find('.undo').on('click', 'a', function(e){ e.preventDefault(); if(undoTimeout){ clearInterval(undoTimeout); } var $item=$wishlist.find('.wishlist_item.deleted'), product_id=$item.data('product_id'), wishlistID=$item.data('wishlist_id'), wishlistToken=$item.data('wishlist_token'), data={ add_to_wishlist: product_id, wishlist_id:wishlistID, wishlist_token:wishlistToken, }; $item.addClass('undo-deleted') .one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(){ if($wishlist.find('.wishlist_item').length==1){ $wishlist.find('.wishlist_empty_message').addClass('hidden'); } $(this) .off('webkitAnimationEnd oanimationend msAnimationEnd animationend') .removeClass('deleted undo-deleted') .removeAttr('style'); request('undo', data, function(){ resetUndo(); var $wlButtons=$('.yith-wcwl-add-to-wishlist.add-to-wishlist-' + product_id); if($wlButtons.length){ $wlButtons.find('.yith-wcwl-add-button') .show() .removeClass('show') .addClass('hide'); $wlButtons.find('.yith-wcwl-wishlistaddedbrowse') .hide() .removeClass('hide') .addClass('show'); $wlButtons.find('.yith-wcwl-wishlistexistsbrowse') .hide() .removeClass('show') .addClass('hide'); }}); }); }); }; var initAddToCart=function(){ $wishlist.find('.add_to_cart_button.product_type_simple').on('click', function(){ if($wishlist.find('.remove_after_add_to_cart').length){ removeAfterAddToCart=true; $(this).closest('.wishlist_item').find('.remove').trigger('click'); }}); }; var resetUndo=function(){ if(undoTimeout){ clearInterval(undoTimeout); } $wishlist.find('.undo').removeClass('visible'); $wishlist.find('.wishlist_item.deleted').remove(); }; var request=function(type, item, callback){ if(updatingWishlist){ return; } var action=''; if(type=='remove'){ action='learts_remove_wishlist_item'; }else if(type=='undo'){ action='learts_undo_remove_wishlist_item'; }else{ return; } $dropDown.addClass('loading'); $.ajax({ type:'POST', dataType: 'json', url:leartsConfigs.ajax_url, data:{ action: action, item:item }, success:function(response){ if(typeof response.success!='undefined'&&response.success==false){ return false; } updateWishListFragments(type, response); clearInterval(undoTimeout); if(typeof callback!=='undefined'){ callback(response); } $dropDown.removeClass('loading'); updatingWishlist=false; removeAfterAddToCart=false; }, error:function(error){ console.log(error); }, }); }; var updateWishListFragments=function(action, data){ if(action==='remove'||action==='undo'){ if(typeof data.fragments!=='undefined'){ $.each(data.fragments, function(key, value){ if(key==='tm-wishlist'){ var $emptyMessage=$wishlist.find('.wishlist_empty_message'), $button=$wishlist.find('.btn-view-wishlist'); if(action=='remove'&&value.count==0){ $emptyMessage.removeClass('hidden'); $button.addClass('hidden'); }else if(action=='undo'&&value.count==1){ $button.removeClass('hidden'); } $wishlist.find('.wishlist-count').html(value.count); }}); }}else{ $body.trigger('wl_fragment_refresh'); } $body.trigger('wl_fragment_refreshed'); }; wlFragments(); events(); };})(jQuery); (function($){ "use strict"; var $window=$(window), $document=$(document), $body=$('body'); learts.miniCart=function(){ var $minicart=$('.header-minicart'), $dropDown=$minicart.find('.minicart-dropdown-wrapper'), itemsCount=0, updatingMiniCart=false, favicon, undoTimeout, minicart_opened=Cookies.get('learts_minicart_favico_opened'); if(leartsConfigs.shop_add_to_cart_favico_on){ favicon=new Favico({ animation: 'none', bgColor:leartsConfigs.shop_favico_badge_bg_color, textColor: leartsConfigs.shop_favico_badge_text_color, }); } var events=function(){ var initEvents=function(){ initRemove(); initUndo(); itemsCount=parseInt($minicart.first() .find('.minicart-count') .text()); $minicart.find('.product_list_widget').perfectScrollbar({ suppressScrollX: true }); if(minicart_opened=='yes'){ favicon.badge(0); }}; $minicart.on('click', '>.toggle', function(e){ e.preventDefault(); if(! $minicart.hasClass('minicart-open')){ open(); }else{ close(); }}); $body.on('click', '#page-container', function(e){ var $target=$(e.target).closest('.header-minicart'); if(! $target.length){ close(); }}); updateCartFragments('refresh'); $body.on('added_to_cart wc_fragments_refreshed wc_fragments_loaded', function(){ initEvents(); if(leartsConfigs.shop_add_to_cart_favico_on&&minicart_opened!='yes'){ favicon.badge(itemsCount); }}); $body.on('added_to_cart', function(){ if(leartsConfigs.shop_add_to_cart_favico_on){ favicon.badge(itemsCount); Cookies.set('learts_minicart_favico_opened', 'no', { expires: 1, path:'/' }); }}); $document.on('cbox_closed', function(){ updateCartFragments('refresh'); }); $window.on('resize', function(){ learts.setTopValue($dropDown); }); }; var open=function(){ $minicart.addClass('minicart-open'); $body.addClass('minicart-opened'); $minicart.find('.close-btn').on('click', function(e){ e.preventDefault(); close(); }); learts.setTopValue($dropDown); if(leartsConfigs.shop_add_to_cart_favico_on){ favicon.badge(0); Cookies.set('learts_minicart_favico_opened', 'yes', { expires: 1, path:'/' }); }}; var close=function(){ $minicart.removeClass('minicart-open'); $body.removeClass('minicart-opened'); }; var initRemove=function(){ $minicart.find('.woocommerce-mini-cart-item .remove').on('click', function(e){ e.preventDefault(); var $this=$(this), cart_item_key=$this.attr('data-cart_item_key'), $item=$this.closest('.woocommerce-mini-cart-item'); request('remove', cart_item_key, function(){ resetUndo(); $item.addClass('deleted'); $minicart.find('.undo').addClass('visible'); undoTimeout=setTimeout(function(){ resetUndo(); }, 8000); }); }); }; var initUndo=function(){ $minicart.find('.undo').on('click', 'a', function(e){ e.preventDefault(); if(undoTimeout){ clearInterval(undoTimeout); } var $item=$minicart.find('.woocommerce-mini-cart-item.deleted'), cart_item_key=$item.find('.remove').data('cart_item_key'); if($minicart.find('.woocommerce-mini-cart-item').length==1){ $minicart.find('.woocommerce-mini-cart__empty-message').addClass('hidden'); } $item.addClass('undo-deleted') .one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(){ $(this) .off('webkitAnimationEnd oanimationend msAnimationEnd animationend') .removeClass('deleted undo-deleted') .removeAttr('style'); request('undo', cart_item_key, function(){ resetUndo(); }); }); }); }; var resetUndo=function(){ if(undoTimeout){ clearInterval(undoTimeout); } $minicart.find('.undo').removeClass('visible'); $minicart.find('.woocommerce-mini-cart-item.deleted').remove(); }; var request=function(type, cart_item_key, callback){ if(updatingMiniCart){ return; } var action=''; if(type=='remove'){ action='learts_remove_cart_item'; }else if(type=='undo'){ action='learts_undo_remove_cart_item'; }else{ return; } $dropDown.addClass('loading'); updatingMiniCart=true; $.ajax({ type:'POST', dataType: 'json', url:leartsConfigs.ajax_url, data:{ action: action, item:cart_item_key }, success:function(response){ updateCartFragments(type, response); clearInterval(undoTimeout); if(typeof callback!=='undefined'){ callback(response); } $dropDown.removeClass('loading'); updatingMiniCart=false; }, error:function(error){ console.log(error); }, }); }; var updateCartFragments=function(action, data){ if(action==='remove'||action==='undo'){ if(typeof data.fragments!=='undefined'){ $.each(data.fragments, function(key, value){ if(key==='tm-minicart'){ var $emptyMessage=$minicart.find('.woocommerce-mini-cart__empty-message'), $total=$minicart.find('.woocommerce-mini-cart__total'), $buttons=$minicart.find('.woocommerce-mini-cart__buttons'), $minicartMessage=$minicart.find('.minicart-message'); if(action=='remove'&&value.count==0){ $emptyMessage.removeClass('hidden'); $total.addClass('hidden'); $buttons.addClass('hidden'); $minicartMessage.addClass('hidden'); }else if(action=='undo'&&value.count==1){ $total.removeClass('hidden'); $buttons.removeClass('hidden'); $minicartMessage.removeClass('hidden'); } $minicart.find('.minicart-count').html(value.count); $minicart.find('.woocommerce-mini-cart__total .woocommerce-Price-amount') .html(value.total); }}); } if($body.hasClass('woocommerce-cart')){ $body.trigger('wc_update_cart'); }} $body.trigger('wc_fragments_refreshed'); }; events(); };})(jQuery); (function($){ "use strict"; var $window=$(window), $document=$(document), $body=$('body'), w=$window.width(); learts.shop=function(){ var $products=$('.products'), $carousel=$('.categories-carousel'); if(! $products.length){ return; } var categoriesCarousel=function(){ if(! leartsConfigs.is_shop){ return; } if(! $carousel.length){ return; } var itemCount=parseInt($carousel.attr('data-carousel')); $carousel.slick({ accessibility:false, slidesToShow:itemCount, slidesToScroll: itemCount, infinite:true, arrows:false, dots:true, responsive:[{ breakpoint: 992, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ centerMode:true, slidesToShow:1, slidesToScroll: 1, }, }], }); } var categoriesMenu=function(){ var $menu=$('.product-categories-menu'); if(! $menu){ return; } if(w > 991){ var menuWidth=0; $menu.find('li').each(function(){ menuWidth +=$(this).outerWidth(true); }); $menu.width(Math.round(menuWidth) + 5); $menu.parent().perfectScrollbar({ suppressScrollY: true }); }else{ $menu.perfectScrollbar(); } $body.on('click', '.show-categories-menu', function(e){ e.preventDefault(); var $this=$(this); if($menu.hasClass('open')){ $this.removeClass('open'); $menu.removeClass('open').slideUp(200); }else{ $this.addClass('open'); $menu.addClass('open').slideDown(200); var scrollTo=$this.offset().top; if(leartsConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } if($('#wpadminbar').length&&$('#wpadminbar') .css('position')=='fixed'){ scrollTo -=$('#wpadminbar').height(); } $body.animate({ scrollTop: scrollTo, }, 600); }}); }; var productCategoriesWidget=function(){ if(! leartsConfigs.categories_toggle){ return; } var _categoriesWidget=document.querySelector('.widget_product_categories .product-categories'); if(_categoriesWidget){ _categoriesWidget.classList.add('has-toggle'); } var _childrens=[].slice.call(document.querySelectorAll('.widget_product_categories ul li ul.children')); if(_childrens){ _childrens.forEach(function(_children){ var _i=document.createElement('i'); _i.classList.add('fa'); _i.classList.add('ion-android-add'); _children.parentNode.insertBefore(_i, _children.parentNode.firstChild); }); } var _toggles=[].slice.call(document.querySelectorAll('.widget_product_categories ul li.cat-parent i')); _toggles.forEach(function(_toggle){ _toggle.addEventListener('click', function(){ var _parent=_toggle.parentNode; if(_parent.classList.contains('expand')){ _parent.classList.remove('expand'); $(_parent).children('ul.children').slideUp(200); }else{ _parent.classList.add('expand'); $(_parent).children('ul.children').slideDown(200); }}); }); var _parents=[].slice.call(document.querySelectorAll('.widget_product_categories ul li.cat-parent')); _parents.forEach(function(_parent){ if(_parent.classList.contains('current-cat')||_parent.classList.contains('current-cat-parent')){ _parent.classList.add('expand'); $(_parent).children('ul.children').show(); }else{ $(_parent).children('ul.children').hide(); } $('.widget_product_categories li.cat-parent.expand').find('> ul.children').show(); }); }; var wooPriceSlider=function(){ if(typeof woocommerce_price_slider_params==='undefined'){ return false; } $('input#min_price, input#max_price').hide(); $('.price_slider, .price_label').show(); var min_price=$('.price_slider_amount #min_price').data('min'), max_price=$('.price_slider_amount #max_price').data('max'), current_min_price=parseInt(min_price, 10), current_max_price=parseInt(max_price, 10); if(typeof $products!='undefined'&&typeof $products.attr('data-min_price')!='undefined'&&$products.attr('data-min_price').length){ current_max_price=parseInt($products.attr('data-min_price'), 10); } if(typeof $products!='undefined'&&typeof $products.attr('data-max_price')!='undefined'&&$products.attr('data-max_price').length){ current_max_price=parseInt($products.attr('data-max_price'), 10); } $('.price_slider').slider({ range:true, animate: true, min:min_price, max:max_price, values:[current_min_price, current_max_price], create:function(){ $('.price_slider_amount #min_price') .val(current_min_price); $('.price_slider_amount #max_price') .val(current_max_price); $(document.body) .trigger('price_slider_create', [current_min_price, current_max_price]); }, slide:function(event, ui){ $('input#min_price').val(ui.values[0]); $('input#max_price').val(ui.values[1]); $(document.body) .trigger('price_slider_slide', [ui.values[0], ui.values[1]]); }, change:function(event, ui){ $(document.body) .trigger('price_slider_change', [ui.values[0], ui.values[1]]); }, }); setTimeout(function(){ $(document.body) .trigger('price_slider_create', [current_min_price, current_max_price]); }, 300); }; var productClass=function(){ [].slice.call(document.querySelectorAll('.products')).forEach(function(_products){ var _product=[].slice.call(_products.querySelectorAll('.product')); if(_product.length){ var _firstProduct=_product[0], productWidth=Math.round(_firstProduct.clientWidth), windowWidth=window.innerWidth, minWidth=155, extraSmallWidth=150, maxWidth=300, extraLargeWidth=600; if(windowWidth > 768){ minWidth=240; } if(windowWidth > 992){ extraSmallWidth=234; minWidth=235; } if(windowWidth > 1200){ extraSmallWidth=200; minWidth=270; } _product.forEach(function(_p){ if(productWidth < minWidth){ _p.classList.add('small-product'); }else{ _p.classList.remove('small-product'); } if(productWidth < extraSmallWidth){ _p.classList.add('extra-small-product'); }else{ _p.classList.remove('extra-small-product'); } if(windowWidth > 1200&&productWidth > maxWidth&&_p.classList.contains('col-xl-4')){ _p.classList.add('large-product'); }else{ _p.classList.remove('large-product'); } if(windowWidth > 1200&&productWidth > extraLargeWidth&&( _p.classList.contains('col-xl-6')||_p.classList.contains('col-xl-1') )){ _p.classList.add('extra-large-product'); }else{ _p.classList.remove('extra-large-product'); }}); } $products.trigger('arrangeComplete'); }); }; var wishlistButton=function(){ if(typeof mojs=='undefined'){ return; } var burst=new mojs.Burst({ left:0, top:0, radius:{ 4: 32 }, angle:45, count:14, children: { radius:2.5, fill:leartsConfigs.wishlist_burst_color, scale:{ 1:0, easing: 'quad.in' }, pathScale:[.8, null], degreeShift: [13, null], duration:[500, 700], easing:'quint.out' }}); $('body').on('click', '.yith-wcwl-add-button.animated-wishlist .add_to_wishlist', function(){ var $this=$(this), offset=$this.offset(), width=$this.width(), height=$this.height(), coords={ x: offset.left + width / 2, y: offset.top + height / 2 }; burst.tune(coords).replay(); }); }; var initAfterAjax=function(){ events(); $('.woocommerce-ordering').on('change', 'select.orderby', function(){ $(this).closest('form').submit(); }); learts.reInitSwatches(); }; var ajaxShop=function(){ if(! leartsConfigs.shop_ajax_on){ return; } if(! leartsConfigs.is_shop){ return; } var ajaxLinks='.woocommerce-pagination a, .widget-area a, .shop-toolbar a, .filter-widgets a, .shop-menu a, .active-filters a', scrollToTop=function(){ $('html, body').stop().animate({ scrollTop: $('.main-container').offset().top - 100, }, 400); }; $body.on('click', 'nav.woocommerce-pagination a', function(){ scrollToTop(); }); $document.pjax(ajaxLinks, '.main-container', { timeout:10000, scrollTo: false, fragment: '.main-container', }); $document.on('click', '.widget_price_filter form .button', function(){ var form=$('.widget_price_filter form'); $.pjax({ container: '.main-container', fragment:'.main-container', timeout:10000, url:form.attr('action'), data:form.serialize(), scrollTo:false, }); return false; }); $document.on('pjax:error', function(xhr, textStatus, error, options){ console.log('pjax error ' + error); }); $document.on('pjax:start', function(xhr, options){ scrollToTop(); $body.addClass('ajax-loading'); }); $document.on('pjax:complete', function(xhr, textStatus, options){ initAfterAjax(); scrollToTop(); $body.removeClass('ajax-loading'); }); $document.on('pjax:end', function(xhr, textStatus, options){ $body.removeClass('ajax-loading'); }); $document.on('yith-wcan-ajax-loading', function(){ var $yit_wcan=$('.yit-wcan-container'); if($yit_wcan.length){ scrollToTop(); }}); }; var shopMasonry=function(){ if(! leartsConfigs.is_shop){ return; } $products.isotope({ layoutMode:'fitRows', itemSelector:'.product', transitionDuration: '0.5s' }); $products.imagesLoaded().progress(function(){ $products.isotope('layout'); }); $products.on('arrangeComplete', function(){ setTimeout(function(){ addActiveClassforColSwitcher(); }, 500); }); }; var columnSwitcher=function(){ if(! $('.col-switcher').length){ return; } addActiveClassforColSwitcher(); var $colSwitcher=$('.col-switcher'), $product=$('.archive.woocommerce .products .product'); $body.on('click', '#page-container', function(e){ var $target=$(e.target).closest('.col-switcher'); if(! $target.length){ $colSwitcher.removeClass('open'); }}); $colSwitcher.find('a').unbind('click').on('click', function(e){ e.preventDefault(); var $this=$(this), windowWidth=$window.width(), col=$this.attr('data-col'), removeClasses='', addClasses=''; Cookies.set('learts_shop_columns', col, { expires: 1, path:'/' }); if(0==12 % col){ col=12 / col; }else{ if(5==col){ col='is-5'; }} $colSwitcher.find('a').removeClass('active'); $this.addClass('active'); if(windowWidth <=544){ removeClasses='col-xs-2 col-xs-3 col-xs-4 col-xs-is-5 col-xs-6 col-xs-12'; addClasses='col-xs-12'; }else if(windowWidth >=545&&windowWidth <=767){ removeClasses='col-sm-2 col-sm-3 col-sm-4 col-sm-is-5 col-sm-6 col-sm-12'; addClasses='col-sm-6'; }else if(windowWidth >=768&&windowWidth <=991){ removeClasses='col-md-2 col-md-3 col-md-4 col-md-is-5 col-md-6 col-md-12'; addClasses='col-md-4'; }else if(windowWidth >=992&&windowWidth <=1199){ removeClasses='col-lg-2 col-lg-3 col-lg-4 col-lg-is-5 col-lg-6 col-lg-12'; addClasses='col-lg-' + col; }else if(windowWidth >=1200){ removeClasses='col-xl-2 col-xl-3 col-xl-4 col-xl-is-5 col-xl-6 col-xl-12'; addClasses='col-xl-' + col; } $product.removeClass(removeClasses).addClass(addClasses); $products.trigger('arrangeComplete'); shopMasonry(); productClass(); }); if(Cookies.get('learts_shop_columns')){ $colSwitcher.find('a[data-col="' + Cookies.get('learts_shop_columns') + '"]').trigger('click'); }}; var addActiveClassforColSwitcher=function(){ var $colSwitcher=$('.col-switcher'); if(! $colSwitcher.length){ return; } var width=$('.products').width(), pWidth=$('.product-loop').outerWidth(), col=Cookies.get('learts_shop_columns') ? Cookies.get('learts_shop_columns'):Math.round(width / pWidth); $colSwitcher.find('a').removeClass('active'); $colSwitcher.find('a[data-col="' + col + '"]').addClass('active'); }; var layerNavDropdown=function(){ if(! leartsConfigs.is_shop){ return; } $('.widget_tm_layered_nav').on('change', 'select', function(){ var slug=$(this).val(), href=$(this).attr('data-filter-url').replace('learts_FILTER_VALUE', slug), pseudoLink=$(this).siblings('.filter-pseudo-link'); pseudoLink.attr('href', href); pseudoLink.trigger('click'); }); }; var filtersArea=function(){ if(! leartsConfigs.is_shop){ return; } var _filters=document.querySelector('.filter-widgets'); if(_filters){ $(_filters).removeClass('filters-opened').stop().hide(); } $('.open-filters').unbind('click').on('click', function(e){ e.preventDefault(); var _filters=document.querySelector('.filter-widgets'); if(_filters.classList.contains('filters-opened')){ closeFilters(); }else{ openFilters(); }}); var openFilters=function(){ var _filters=document.querySelector('.filter-widgets'), _btnFilter=document.querySelector('.open-filters'); _filters.classList.add('filters-opened'); $(_filters).stop().slideDown(350); _btnFilter.classList.add('opened'); setTimeout(function(){ $('.filter-widgets .widget_tm_layered_nav ul.show-display-list') .perfectScrollbar({ suppressScrollX: true }); $('.filter-widgets .widget_tm_layered_nav ul.show-display-list.show-labels-off li') .each(function(){ $(this).find('.filter-swatch').removeClass('hint--top').addClass('hint--right'); }); }, 500); }; var closeFilters=function(){ var _filters=document.querySelector('.filter-widgets'), _btnFilter=document.querySelector('.open-filters'); _filters.classList.remove('filters-opened'); $(_filters).stop().slideUp(350); _btnFilter.classList.remove('opened'); };}; var productTabs=function(){ if(! leartsConfigs.is_shop){ return; } $('.shop-toolbar .product-tabs a').on('click', function(e){ e.preventDefault(); var $this=$(this), $li=$this.parent(), $ul=$this.closest('.product-tabs'), filterValue=$li.attr('data-filter'); $ul.find('.active').removeClass('active'); $li.addClass('active'); $('.products.ajax-products').isotope({ filter: filterValue }); }); }; var events=function(){ $('.shop-toolbar select.orderby').niceSelect(); $('.product-categories-select .list').perfectScrollbar(); $('.widget_tm_layered_nav ul.show-display-list').perfectScrollbar(); $('.widget_product_categories ul.product-categories').perfectScrollbar({ suppressScrollX: true }); categoriesCarousel(); categoriesMenu(); productCategoriesWidget(); wooPriceSlider(); shopMasonry(); wishlistButton(); columnSwitcher(); layerNavDropdown(); filtersArea(); productTabs(); setTimeout(function(){ productClass(); }, 500); }; events(); ajaxShop(); $window.on('popstate', function(){ productCategoriesWidget(); categoriesMenu(); columnSwitcher(); filtersArea(); wishlistButton(); learts.reInitSwatches(); learts.ajaxLoadMore(); }); $window.on('resize', function(){ if($products.closest('.tm-shortcode').length||$products .closest('.up-sells').length||$products .closest('.cross-sells').length||$products .closest('.related').length){ $products.addClass('grid'); } if($(this).width()!=w){ productClass(); if(Cookies.get('learts_shop_columns')&&$('.col-switcher').length&&$(this).width() >=992){ $('.col-switcher').find('a[data-col="' + Cookies.get('learts_shop_columns') + '"]').trigger('click'); }} }); };})(jQuery); (function($){ "use strict"; var $window=$(window), $document=$(document), $body=$('body'); learts.quickView=function(){ var $quickView=$('#woo-quick-view'); var events=function(){ var disable=false, sliderFinalWidth=leartsConfigs.quickview_image_width, maxQuickWidth=960; $body.on('click', '.quick-view-btn', function(e){ e.preventDefault(); if(disable){ return false; } var $this=$(this), $productThumb=$this.closest('.product-loop').find('.product-thumb'); if(! $productThumb.length){ return; } var pid=$this.attr('data-pid'), selectedImage=$productThumb.find('img.wp-post-image'); var cache=sessionStorage.getItem('learts_quickview_' + pid); if(cache){ $quickView.html(cache); if($quickView.hasClass('animated-quick-view')){ $body.addClass('quick-view-opened'); animateQuickView(selectedImage, sliderFinalWidth, maxQuickWidth, 'open'); }else{ magnificPopupQuickview(); } reInitEvents(); return; } $this.addClass('loading'); $productThumb.addClass('loading'); disable=true; $.ajax({ url:leartsConfigs.ajax_url, data:{ action: 'learts_quick_view', pid:pid, }, timeout: 10000, success: function(response){ $quickView.empty().html(response).attr('data-product-id', pid); if($quickView.hasClass('animated-quick-view')){ $body.addClass('quick-view-opened'); animateQuickView(selectedImage, sliderFinalWidth, maxQuickWidth, 'open'); }else{ magnificPopupQuickview(); } $this.removeClass('loading'); $productThumb.removeClass('loading'); disable=false; reInitEvents(); }, error:function(error){ console.log(error); $this.removeClass('loading'); $productThumb.removeClass('loading'); disable=false; }, }); }); $body.on('click', function(e){ if($(e.target).is('.quick-view-close')||$(e.target) .is('body.quick-view-opened #page-container')){ e.preventDefault(); closeQuickView(sliderFinalWidth, maxQuickWidth); }}); $document.keyup(function(event){ if(event.which=='27'){ closeQuickView(sliderFinalWidth, maxQuickWidth); }}); $window.on('resize', function(){ if($quickView.hasClass('is-visible')){ window.requestAnimationFrame(resizeQuickView); }}); }; var resizeQuickView=function(){ var quickViewLeft=( $window.width() - $quickView.width() ) / 2, quickViewTop=( $window.height() - $quickView.height() ) / 2; $quickView.css({ 'top':quickViewTop, 'left': quickViewLeft, }); if($('.quick-view-carousel img').length > 1&&$('.quick-view-carousel') .hasClass('slick-slider')){ $('.quick-view-carousel').slick('setPosition'); }}; var closeQuickView=function(finalWidth, maxQuickWidth){ var selectedImage=$('.empty-box').find('.woocommerce-LoopProduct-link img'); if($('.quick-view-carousel img').length > 1){ $('.quick-view-carousel').slick('unslick'); } if($quickView.hasClass('add-content')){ animateQuickView(selectedImage, finalWidth, maxQuickWidth, 'close'); }else{ if(typeof selectedImage!='undefined'){ closeNoAnimation(selectedImage); }} var oldID=$quickView.attr('data-product-id'); if(oldID&&! sessionStorage.getItem('learts_quickview_' + oldID)){ $quickView.find('.summary').perfectScrollbar('destroy'); sessionStorage.setItem('learts_quickview_' + oldID, $quickView.html()); }}; var closeNoAnimation=function(image){ var parentListItem=image.parents('li'); if(typeof image.offset()=='undefined'){ return; } var topSelected=image.offset().top - $window.scrollTop(), leftSelected=image.offset().left, widthSelected=image.width(); $body.removeClass('overlay-layer'); parentListItem.removeClass('empty-box'); $quickView.removeClass('add-content animate-width is-visible') .css({ 'top':topSelected, 'left':leftSelected, 'width': widthSelected, }); }; var animateQuickView=function(image, finalWidth, maxQuickWidth, animationType){ var target='#woo-quick-view', timeline=anime.timeline(), parentListItem=image.parents('.product-loop'), topSelected=image.offset().top - $window.scrollTop(), leftSelected=image.offset().left, widthSelected=image.width(), windowWidth=$window.width(), windowHeight=$window.height(), finalLeft=( windowWidth - finalWidth ) / 2, finalHeight=leartsConfigs.quickview_image_height, finalTop=( windowHeight - finalHeight ) / 2, quickViewWidth=( windowWidth * .8 < maxQuickWidth ) ? windowWidth * .8:maxQuickWidth, quickViewLeft=( windowWidth - quickViewWidth ) / 2; if(animationType=='open'){ parentListItem.addClass('empty-box'); timeline.add({ targets:target, top:[topSelected, finalTop + 'px'], left:[leftSelected, finalLeft + 'px'], width:[widthSelected, finalWidth + 'px'], duration:1800, elasticity: 200, begin:function(anim){ $quickView.addClass('is-visible'); }, }).add({ targets:target, left:quickViewLeft + 'px', width:quickViewWidth + 'px', duration: 400, easing:'easeInQuad', begin:function(anim){ $quickView.addClass('animate-width'); }, complete: function(anim){ if($('.quick-view-carousel img').length > 1){ var settings=JSON.parse($('.quick-view-carousel').attr('data-carousel')); $('.quick-view-carousel').slick(settings); } $quickView.addClass('add-content'); }}); }else{ timeline=anime.timeline(); timeline.add({ targets:target, left:[quickViewLeft + 'px', finalLeft + 'px'], width:[quickViewWidth + 'px', finalWidth + 'px'], duration: 400, easing:'easeInQuad', begin:function(anim){ $quickView.removeClass('add-content'); }, complete: function(anim){ $body.removeClass('quick-view-opened'); }}).add({ targets:target, top:[finalTop + 'px', topSelected], left:[finalLeft + 'px', leftSelected], width:[finalWidth + 'px', widthSelected], duration: 500, easing:'easeInQuad', begin:function(anim){ $quickView.removeClass('animate-width'); }, complete: function(anim){ $quickView.removeClass('is-visible'); $body.removeClass('quick-view-opened'); parentListItem.removeClass('empty-box'); }}); }}; var magnificPopupQuickview=function(){ $.magnificPopup.open({ items:{ src: $quickView, }, mainClass: 'mfp-fade', type:'inline', callbacks: { open:function(){ $('.quick-view-carousel').slick({ accessibility: false, infinite:false, dots:true, arrows:false }); }, afterClose: function(){ if($('.quick-view-carousel img').length > 1){ var carousel=JSON.parse($('.quick-view-carousel').attr('data-carousel')); $('.quick-view-carousel').slick(carousel); }}, }, }); }; var initAddToCart=function(){ $body.on('submit', '#woo-quick-view form.cart', function(e){ e.preventDefault(); var $this=$(this), $loading=$('#woo-quick-view .quickview-loading'), $text=$loading.find('> span'), data=$.parseParams($this.serialize()); $text.text(leartsConfigs.adding_to_cart_text); $loading.removeClass('added').removeClass('error').fadeIn(200); data.action='learts_ajax_add_to_cart'; data.pid=$this.find('button[name="add-to-cart"]').val(); if($this.hasClass('variations_form')||$this.find('.group_table').length){ data.pid=data['add-to-cart']; delete data['add-to-cart']; } $this.find('.single_add_to_cart_button').blur(); $.ajax({ type:'POST', url:leartsConfigs.ajax_url, data:data, success: function(response){ if('undefined'!==typeof response.fragments){ $text.text(leartsConfigs.added_to_cart_text); $loading.addClass('added'); $body.trigger('wc_fragment_refresh'); $body.trigger('wc_fragments_refreshed'); setTimeout(function(){ $body.trigger('added_to_cart'); }, 500); }else{ $text.text(response.message); $loading.addClass('error'); $.growl.error({ location: 'tr', title:'', size:'large', message:'
    ' + response.message + '
' }); } $('#woo-quick-view .summary').animate({ scrollTop: 0 }, 300); $loading.delay(3200).fadeOut(); }, error:function(error){ $loading.delay(3200).fadeOut(); if(wc_add_to_cart_params.cart_redirect_after_add==='yes'){ window.location=wc_add_to_cart_params.cart_url; } $.growl.error({ location: 'tr', title:'', size:'large', message:'
    Sorry, something went wrong. Please try again
' }); console.log(error); }, }); }); }; var variationHandler=function(){ $('select.isw-selectbox').niceSelect(); var $form=$quickView.find('form.isw-swatches.variations_form'); $form.on('show_variation', function(e, variation){ if(variation&&variation.image&&variation.image.src&&variation.image.src.length > 1){ var $carousel=$('.quick-view-carousel.slick-slider'), $slide=$carousel.find('img[src="' + variation.image.src + '"]:not(.slick-cloned):not(.first-image)'), index=$slide.attr('data-slick-index'), $product_img=$carousel.find('.first-image'); if($slide.length){ if($carousel.hasClass('slick-initialized')){ $carousel.slick('slickGoTo', parseInt(index)); } $product_img.wc_reset_variation_attr('src'); $product_img.wc_reset_variation_attr('width'); $product_img.wc_reset_variation_attr('height'); $product_img.wc_reset_variation_attr('srcset'); $product_img.wc_reset_variation_attr('sizes'); $product_img.wc_reset_variation_attr('title'); $product_img.wc_reset_variation_attr('alt'); }else{ if($carousel.hasClass('slick-initialized')){ $carousel.slick('slickGoTo', parseInt(0)); } $product_img.wc_set_variation_attr('src', variation.image.src); $product_img.wc_set_variation_attr('height', variation.image.src_h); $product_img.wc_set_variation_attr('width', variation.image.src_w); $product_img.wc_set_variation_attr('srcset', variation.image.srcset); $product_img.wc_set_variation_attr('sizes', variation.image.sizes); $product_img.wc_set_variation_attr('title', variation.image.title); $product_img.wc_set_variation_attr('alt', variation.image.alt); }} }); } var reInitEvents=function(){ $quickView.find('.summary').css('max-height', $quickView.find('.woocommerce-main-image') .attr('height') + 'px'); $quickView.find('.summary').perfectScrollbar({ suppressScrollX: true }); learts.reInitSwatches(); learts.quantityField(); variationHandler(); }; events(); initAddToCart(); }})(jQuery); ( function($){ "use strict"; var $body=$('body'); learts.notification=function(){ var config={ location: 'tr', title:'', size:'large', }; var events=function(){ $body.on('click', 'a.add_to_cart_button', function(){ $('a.add_to_cart_button').removeClass('recent-added'); $(this).addClass('recent-added'); if($(this).is('.product_type_variable, .isw-ready')){ $(this).addClass('loading'); }}); $body.on('click', 'button.single_add_to_cart_button', function(){ $('button.single_add_to_cart_button').removeClass('recent-added'); $(this).addClass('recent-added'); }); $body.on('click', '.add_to_wishlist', function(){ $(this).addClass('loading'); }); }; var addToCartNotification=function(){ $body.on('added_to_cart', function(){ $('.add_to_cart_button.product_type_variable.isw-ready').removeClass('loading'); var $recentAdded=$('.add_to_cart_button.recent-added, button.single_add_to_cart_button.recent-added'), $img=$recentAdded.closest('.product-loop').find('img.wp-post-image'), pName=$recentAdded.attr('data-product_name'); if(! $img.length){ $img=$recentAdded.closest('.wishlist_item') .find('.wishlist_item_product_image img'); } if(! $img.length){ $img=$recentAdded.closest('.summary') .prev() .find('.woocommerce-main-image img'); } setTimeout(function(){ $recentAdded.removeClass('added').removeClass('recent-added'); $recentAdded.next('.added_to_cart').remove(); }, 5000); if(typeof pName=='undefined'||pName==''){ pName=$recentAdded.closest('.summary').find('.product_title').text().trim(); } if(typeof pName!=='undefined'){ config['message']=( $img.length ? '' + pName + '':'' ) + '

' + pName + ' ' + leartsConfigs.added_to_cart_notification_text + ' ' + leartsConfigs.view_cart_notification_text + '

'; }else{ config['message'] = leartsConfigs.added_to_cart_text + ' ' + leartsConfigs.view_cart_notification_text + ''; } $.growl.notice(config); }); }; var addToWishlistNotification=function(){ $body.on('added_to_wishlist', function(){ $('#yith-wcwl-popup-message').remove(); config['message'] = '

' + leartsConfigs.added_to_wishlist_text + ' ' + leartsConfigs.browse_wishlist_text + '

'; $.growl.notice(config); }); }; events(); if(leartsConfigs.shop_add_to_cart_notification_on){ addToCartNotification(); } if(leartsConfigs.shop_wishlist_notification_on){ addToWishlistNotification(); }} } )(jQuery); ( function($){ "use strict"; var $body=$('body'); learts.compare=function(){ $body.on('click', '.compare-btn .compare', function(){ $(this).parent().addClass('loading'); }); $body.on('yith_woocompare_open_popup', function(){ $('.compare-btn').removeClass('loading'); $body.addClass('compare-opened'); }); $body.on('click', '#cboxClose, #cboxOverlay', function(){ $body.removeClass('compare-opened'); }); }} )(jQuery); ( function($){ "use strict"; var $document=$(document), $body=$('body'); learts.ajaxAddToCart=function(){ if(typeof wc_add_to_cart_params!="undefined"&&wc_add_to_cart_params.cart_redirect_after_add==='yes'){ return; } $body.on('click', '.product .summary.ajax-add-to-cart .single_add_to_cart_button', function(){ var $button=$(this); if($button.hasClass('product_type_variable')){ return true; } if($button.closest('.product-type-external').length){ return true; } if($button.hasClass('disabled')||$button.hasClass('wc-variation-selection-needed')||$button.hasClass('wc-variation-is-unavailable')){ return false; } if($document.data('processing')===1){ return false; } $document.data('processing', 1); $document.data('processing_once', 0); var $form=$button.closest('form.cart'), buttonDefaultCusor=$button.css('cursor'), data=$.parseParams($form.serialize()); if(! $form.hasClass('variations_form')&&! $form.find('.group_table').length){ data['add-to-cart']=$form.find('button[name="add-to-cart"]').val(); } $body.css('cursor', 'wait'); $button.css('cursor', 'wait').blur().addClass('loading'); $.ajax({ type:'POST', url:$form.attr('action'), data:data, success: function(response){ if($(response).find('.woocommerce-error').length > 0){ appendMessageDiv(response, 'woocommerce-error'); $.growl.error({ location: 'tr', title:'', size:'large', message:'
    ' + $('.woocommerce-error') .html() + '
' }); }else if($(response).find('.woocommerce-message').length > 0){ appendMessageDiv(response, 'woocommerce-message'); $body.trigger('added_to_cart'); $body.trigger('wc_fragment_refresh'); } $document.data('processing_once', 1); $body.css('cursor', 'default'); $button.css('cursor', buttonDefaultCusor).removeClass('loading'); }, error:function(error){ console.log(error); $document.data('processing_once', 1); $document.data('processing', 0); $button.removeClass('loading'); }, }); return false; }); var isElementInViewport=function($el){ if(! $el.length){ return true; } var rect=$el[0].getBoundingClientRect(); return ( rect.top >=0&&rect.left >=0&&rect.bottom <=( window.innerHeight||document.documentElement.clientHeight )&&rect.right <=( window.innerWidth||document.documentElement.clientWidth ) ); }; var getMessageParentDiv=function(response, woocommerce_msg){ var $product=$('.main-container>.site-content>.product.type-product:eq(0)'), $result; if($product.length > 0){ $result=$product; }else{ var id=$(response).find('.' + woocommerce_msg).parent().attr('id'); if(id){ $result=$('#' + id).children().eq($('#' + id).children().length - 1); }else{ var classes=$(response).find('' + woocommerce_msg).parent().attr('class'); $result=$document.find("div[class='" + classes + "']") .children() .eq($document.find("div[class='" + classes + "']") .children().length - 1); }} return $result.find('>.container>.row>.col-xs-12>.row'); }; var appendMessageDiv=function(response, woocommerce_msg){ var divToInsert=getMessageParentDiv(response, woocommerce_msg), message='.' + woocommerce_msg; $document.find('.woocommerce-error').remove(); $document.find('.woocommerce-message').remove(); $(divToInsert) .before($(response).find(message).wrap('
').parent().html()) .fadeIn(); var isInViewport=isElementInViewport($document.find(message)); if(! isInViewport){ var scrollTo=$(message).offset().top; if(leartsConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } $('html, body').animate({ scrollTop: scrollTo - 50 }, 500); } $document.data('processing', 0); };}; } )(jQuery); ( function($){ "use strict"; learts.ajaxLoadMore=function(){ var $body=$('body'), $switcherFiveColumns=$('.ti-layout-grid4-alt'), $switcherFourColumns=$('.ti-layout-grid3-alt'), $switcherThreeColumns=$('.ti-layout-grid2-alt'), $columnSwitcher=leartsConfigs.categories_columns, $activeCol=$('.col-switcher').find('.active'), $col=$activeCol.attr('data-col'); if($col==5){ $columnSwitcher=5; } if($col==4){ $columnSwitcher=4; } if($col==3){ $columnSwitcher=3; } $switcherFiveColumns.on('click', function(e){ e.preventDefault(); $columnSwitcher=5; }); $switcherFourColumns.on('click', function(e){ e.preventDefault(); $columnSwitcher=4; }); $switcherThreeColumns.on('click', function(e){ e.preventDefault(); $columnSwitcher=3; }); var _loadMoreBtns=[].slice.call(document.querySelectorAll('.learts-loadmore-btn')), loading=false, loadPosts=function(_el){ var _loadMoreWrap=_el.parentNode, atts=JSON.parse(_loadMoreWrap.getAttribute('data-atts')), btn_columns=parseInt(atts.columns), posts_per_page=parseInt(atts.posts_per_page), total=parseInt(atts.total), view=atts.view, _wrapContainer=document.querySelector(atts.container), pAttr=JSON.parse(_wrapContainer.getAttribute('data-atts')), filter=_loadMoreWrap.getAttribute('data-filter'), column_loadmore_post=1; if(leartsConfigs.archive_display_type&&leartsConfigs.archive_display_type=='list'){ column_loadmore_post=1; } if(leartsConfigs.archive_display_type&&leartsConfigs.archive_display_type=='grid'||leartsConfigs.archive_display_type=='masonry'||leartsConfigs.archive_display_type=='full-grid'){ column_loadmore_post=2; if($('.inner-page-wrap').hasClass('has-no-sidebars')){ column_loadmore_post=3; }} if(leartsConfigs.portfolio_columns&&leartsConfigs.portfolio_columns=='3'){ column_loadmore_post=3; } if(leartsConfigs.portfolio_columns&&leartsConfigs.portfolio_columns=='4'){ column_loadmore_post=4; } if(leartsConfigs.portfolio_columns&&leartsConfigs.portfolio_columns=='5'){ column_loadmore_post=5; } var data={ action:'learts_ajax_load_more', post_type:atts.post_type, posts_per_page: posts_per_page, category:filter, view:view, img_size:atts.img_size, exclude:[] }; if(atts.post_type=='product'){ data.columns=($columnSwitcher&&$body.hasClass('post-type-archive-product')) ? $columnSwitcher:btn_columns; }else{ data.columns=column_loadmore_post; } var _wrapper=null; if(atts.post_type=='post'){ if(_loadMoreWrap.classList.contains('learts-pagination')){ _wrapper=_wrapContainer; }else{ _wrapper=_wrapContainer.querySelector('.posts'); }} if(atts.post_type=='portfolio'){ if(_loadMoreWrap.classList.contains('learts-pagination')){ _wrapper=_wrapContainer; }else{ _wrapper=_wrapContainer.querySelector('.portfolios'); }} if(atts.post_type=='product'){ if(_loadMoreWrap.classList.contains('woocommerce-pagination')){ _wrapper=_wrapContainer; }else{ _wrapper=_wrapContainer.querySelector('.products'); }} if(_wrapper==null||_loadMoreWrap.classList.contains('hidden')){ return; } if(atts.post_type=='post'||atts.post_type==='portfolio'){ if(pAttr!=null){ data.filter=pAttr.filter; data.columns=pAttr.columns; if(pAttr.filter=='category'){ data.cat_slugs=pAttr.cat_slugs; } if(pAttr.filter=='tag'){ data.tag_slugs=pAttr.tag_slugs; } if(atts.orderby!==null){ data.orderby=pAttr.orderby; } if(atts.order!==null){ data.order=pAttr.order; }} } if(atts.post_type=='product'){ if(pAttr==null){ if(atts.data_source==null||atts.data_source==='undefined'){ data.data_source=_loadMoreWrap.getAttribute('data-filter'); }else{ data.data_source=atts.data_source; data.category=atts.category; data.include_children=true; } if(atts.data_source=='categories'){ data.data_source=atts.data_source; data.category=atts.category; data.include_children=true; } if(atts.data_source=='filter'){ data.data_source=atts.data_source; data.tax_array=atts.tax_array; } if(atts.orderby!==null){ data.orderby=atts.orderby; } if(atts.order!==null){ data.order=atts.order; }}else{ data.data_source=pAttr.data_source; if(pAttr.data_source=='category'){ data.category=_loadMoreWrap.getAttribute('data-filter'); data.include_children=pAttr.include_children=='yes'; }else{ var arr_filter=['featured_products','sale_products','best_selling_products','top_rated_products','recent_products']; if(typeof pAttr.data_source!=='undefined'){ data.data_source=_loadMoreWrap.getAttribute('data-filter'); }} if(pAttr.data_source=='product_attribute'){ data.attribute=pAttr.attribute; data.filter=pAttr.filter; } if(pAttr.data_source=='categories'){ data.product_cat_slugs=pAttr.product_cat_slugs; data.include_children=pAttr.include_children=='yes'; } if(pAttr.orderby!==null){ data.orderby=pAttr.orderby; } if(pAttr.order!==null){ data.order=pAttr.order; }} } var className='.product-loop'; if(atts.post_type==='post'){ className='.post-item'; } if(atts.post_type==='portfolio'){ className='.portfolio-item'; } var _posts=[].slice.call(_wrapper.querySelectorAll(className)); _posts.forEach(function(post){ var productID=post.className.match(/post-\d+/gi)[0]; productID=productID.replace('post-', ''); data.exclude.push(productID); }); $.ajax({ method:'POST', url:leartsConfigs.ajax_url, data:data, beforeSend: function(){ loading=true; _loadMoreWrap.classList.add('loading'); }, success:function(response){ if(response){ var iso=Isotope.data(_wrapper); $(_wrapper).append($(response)); imagesLoaded(_wrapper, function(){ var _items=[].slice.call(_wrapper.querySelectorAll('.adding-item')), gridFx=new GridLoaderFx(_wrapper, '.adding-item'); if(atts.post_type=='post'){ learts.fitVideo(); learts.thumbGallery(); } if(atts.post_type=='product'){ learts.reInitSwatches(); } if(iso!=null){ _items.forEach(function(item){ iso.appended(item); }); } _items.forEach(function(item){ item.classList.remove('adding-item'); }); if(_items.length < posts_per_page&&_items.length!==0){ _loadMoreWrap.classList.add('hidden'); } var c=$(_loadMoreWrap).parent(); var a=c.find('.product-filter li a.active').attr('data-page'); var k=a ++; if(a){ atts.paged=a; }else{ atts.paged ++; } console.log(atts); console.log(total); if(atts.paged > total){ $('.learts-loadmore-wrap').addClass('hidden'); } c.find('.product-filter li a.active').attr('data-page', a); _loadMoreWrap.setAttribute('data-atts', JSON.stringify(atts)); }); }else{ _loadMoreWrap.classList.add('hidden'); } _loadMoreWrap.classList.remove('loading'); loading=false; }, error:function(error){ console.log(error); }}); }; _loadMoreBtns.forEach(function(_btn){ _btn.addEventListener('click', function(e){ e.preventDefault(); loadPosts(_btn); }); if(_btn.classList.contains('load-on-scroll')){ var _loadMoreWrap=_btn.parentNode; $(window).on('scroll', function(){ if($('.learts-loadmore-wrap').length){ if($(_loadMoreWrap).offset().top <=$(this).scrollTop() + $(this) .height()&&! loading){ loadPosts(_btn); }} }) }}); };} )(jQuery); (function($){ "use strict"; var $window=$(window), $body=$('body'); learts.product=function(){ if(! document.body.classList.contains('single-product')){ return; } var _productGallery=document.querySelector('.woocommerce-product-gallery'), _mainImageSlider=document.querySelector('.woocommerce-product-gallery__slider'), _thumbnailsSlider=document.querySelector('.thumbnails-slider'); var mainImageSlider=function(){ if(leartsConfigs.product_page_layout=='sticky'||leartsConfigs.product_page_layout=='sticky-fullwidth'){ return; } if($(_mainImageSlider).attr('data-carousel')==null){ $(_mainImageSlider).css({ 'opacity':1, 'visibility': 'visible' }); return; } if(_productGallery.classList.contains('only-featured-image')){ var _zoomTarget=_mainImageSlider.querySelector('.woocommerce-product-gallery__image'); $(_zoomTarget).trigger('zoom.destroy'); return; } var settings=JSON.parse(_mainImageSlider.getAttribute('data-carousel')); $(_mainImageSlider).slick(settings); }; var mainImageZoom=function(){ if(leartsConfigs.zoomEnable=='1'&&$.fn.zoom){ var _zoomTarget=$('.woocommerce-product-gallery__image'), _imageToZoom=_zoomTarget.find('img'); if(_imageToZoom.attr('data-large_image_width') > _productGallery.offsetWidth){ _zoomTarget.trigger('zoom.destroy'); _zoomTarget.zoom({ touch: false }); }} }; var thumbnailsSlider=function(){ if(leartsConfigs.product_page_layout=='sticky'||leartsConfigs.product_page_layout=='sticky-fullwidth'){ return; } if(! _thumbnailsSlider){ return; } var settings=JSON.parse(_thumbnailsSlider.getAttribute('data-carousel')); settings.responsive=[{ breakpoint: 768, settings:{ slidesToShow:4, vertical:false, verticalSwiping: false, arrows:false, dots:true, }, }]; $(_thumbnailsSlider).slick(settings); [].slice.call(_thumbnailsSlider.querySelectorAll('a.slick-slide')).forEach(function(_slide){ _slide.addEventListener('click', function(e){ e.preventDefault(); }); }); }; var lightBoxHandler=function(){ $(_productGallery).off('click', '.woocommerce-product-gallery__image a'); $(_productGallery).on('click', '.lightbox-btn, .woocommerce-product-gallery__image a', function(e){ e.preventDefault(); openPhotoSwipe(getImageIndex(e)); }); } var variationHandler=function(){ var $form=$('form.isw-swatches.variations_form'); if(leartsConfigs.product_page_layout=='sticky'||leartsConfigs.product_page_layout=='sticky-fullwidth'){ return; } $form.on('show_variation', function(e, variation){ if(variation&&variation.image&&variation.image.src&&variation.image.src.length > 1){ var $slide=$(_mainImageSlider) .find('.woocommerce-product-gallery__image[data-thumb="' + variation.image.thumb_src + '"]:not(.slick-cloned)'), index=$slide.index('.woocommerce-product-gallery__image:not(.slick-cloned)'), $product_img_wrap=$(_productGallery) .find('.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder') .eq(0), $product_img=$(_productGallery.querySelector('.wp-post-image')), $product_link=$product_img_wrap.find('a').eq(0); if($slide.length){ if($(_mainImageSlider).hasClass('slick-initialized')){ $(_mainImageSlider).slick('slickGoTo', parseInt(index)); } $product_img.wc_reset_variation_attr('src'); $product_img.wc_reset_variation_attr('width'); $product_img.wc_reset_variation_attr('height'); $product_img.wc_reset_variation_attr('srcset'); $product_img.wc_reset_variation_attr('sizes'); $product_img.wc_reset_variation_attr('title'); $product_img.wc_reset_variation_attr('alt'); $product_img.wc_reset_variation_attr('data-src'); $product_img.wc_reset_variation_attr('data-large_image'); $product_img.wc_reset_variation_attr('data-large_image_width'); $product_img.wc_reset_variation_attr('data-large_image_height'); $product_img_wrap.wc_reset_variation_attr('data-thumb'); $product_link.wc_reset_variation_attr('href'); }else{ if($(_mainImageSlider).hasClass('slick-initialized')){ $(_mainImageSlider).slick('slickGoTo', parseInt(0)); } $product_img.wc_set_variation_attr('src', variation.image.src); $product_img.wc_set_variation_attr('height', variation.image.src_h); $product_img.wc_set_variation_attr('width', variation.image.src_w); $product_img.wc_set_variation_attr('srcset', variation.image.srcset); $product_img.wc_set_variation_attr('sizes', variation.image.sizes); $product_img.wc_set_variation_attr('title', variation.image.title); $product_img.wc_set_variation_attr('alt', variation.image.alt); $product_img.wc_set_variation_attr('data-src', variation.image.full_src); $product_img.wc_set_variation_attr('data-large_image', variation.image.full_src); $product_img.wc_set_variation_attr('data-large_image_width', variation.image.full_src_w); $product_img.wc_set_variation_attr('data-large_image_height', variation.image.full_src_h); $product_img_wrap.wc_set_variation_attr('data-thumb', variation.image.thumb_src); $product_link.wc_set_variation_attr('href', variation.image.full_src); }} }); $form.on('reset_data', function(){ var $product_img_wrap=$(_productGallery) .find('.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder') .eq(0), $product_img=$(_productGallery.querySelector('.wp-post-image')), $product_link=$product_img_wrap.find('a').eq(0), variations=$('.variations').find('tr').length, $selects=$form.find('select'), chosen_count=0; $selects.each(function(){ var value=$(this).val()||''; if(value.length){ chosen_count ++; }}); if(variations > 1&&chosen_count==variations){ $(_mainImageSlider).slick('slickGoTo', 0); } $product_img.wc_reset_variation_attr('src'); $product_img.wc_reset_variation_attr('width'); $product_img.wc_reset_variation_attr('height'); $product_img.wc_reset_variation_attr('srcset'); $product_img.wc_reset_variation_attr('sizes'); $product_img.wc_reset_variation_attr('title'); $product_img.wc_reset_variation_attr('alt'); $product_img.wc_reset_variation_attr('data-src'); $product_img.wc_reset_variation_attr('data-large_image'); $product_img.wc_reset_variation_attr('data-large_image_width'); $product_img.wc_reset_variation_attr('data-large_image_height'); $product_img_wrap.wc_reset_variation_attr('data-thumb'); $product_link.wc_reset_variation_attr('href'); }); } var openPhotoSwipe=function(index){ var pswpElement=document.querySelectorAll('.pswp')[0]; var items=getImages(); if($('body').hasClass('rtl')){ index=items.length - index - 1; items=items.reverse(); } var options={ history:false, showHideOpacity:true, hideAnimationDuration: 333, showAnimationDuration: 333, index:index }; var gallery=new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); gallery.init(); }; var getImages=function(){ var items=[]; [].slice.call(_mainImageSlider.querySelectorAll('a > img')) .forEach(function(_img){ var src=_img.getAttribute('data-large_image'), width=_img.getAttribute('data-large_image_width'), height=_img.getAttribute('data-large_image_height'); if(! $(_img).closest('.woocommerce-product-gallery__image').hasClass('slick-cloned')){ items.push({ src:src, w:width, h:height, title: false }); }}); return items; }; var getImageIndex=function(e){ if(_mainImageSlider.classList.contains('slick-slider')){ return parseInt(_mainImageSlider.querySelector('.slick-current') .getAttribute('data-slick-index')); }else{ return $(e.currentTarget).parent().index(); }}; var scrollToReviews=function(){ if(! $('#reviews').length){ return; } $body.on('click', '.woocommerce-review-link', function(e){ e.preventDefault(); var scrollTo=$('#reviews').offset().top; if(leartsConfigs.sticky_header){ scrollTo -=$('.sticky-header').outerHeight() + $('.woocommerce-Reviews-title') .outerHeight(true); } $('html, body').animate({ scrollTop: scrollTo, }, 600); }); }; var upSellsandRelated=function(){ if($('.upsells .products').find('.product').length < 4&&$('.related .products') .find('.product').length < 4){ return; } $('.upsells .products, .related .products').slick({ slidesToShow:4, slidesToScroll: 4, dots:true, responsive:[{ breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, }, }, { breakpoint: 768, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ dots:false, adaptiveHeight: true, centerPadding:'40px', centerMode:true, slidesToShow:1, slidesToScroll: 1, }, },], }); }; var stickyDetails=function(){ var $details=$('.sticky-row .entry-summary'); $body.trigger('sticky_kit:recalc'); if($window.width() < 992){ return; } if(! $details.length){ return; } var rect=_productGallery.getBoundingClientRect(), left=rect.right, top=60; if($('#wpadminbar').length){ top +=$('#wpadminbar').height(); } if($('.sticky-header').length){ top +=$('.sticky-header').height(); } $details.stick_in_parent({ offset_top: top }).on('sticky_kit:stick', function(){ $(this).removeClass('sticky_kit-bottom').css({ 'left': left, 'top':top, }); }).on('sticky_kit:unstick', function(){ $(this).removeClass('sticky_kit-bottom').css({ 'left': 'auto', 'top':'auto', }); }).on('sticky_kit:bottom', function(){ $(this).addClass('sticky_kit-bottom').css({ 'left': $(_productGallery).outerWidth(), }); }).on('sticky_kit:unbottom', function(){ $(this).removeClass('sticky_kit-bottom').css({ 'left': left, 'top':top, }); }); }; mainImageSlider(); mainImageZoom(); thumbnailsSlider(); lightBoxHandler(); variationHandler(); upSellsandRelated(); scrollToReviews(); stickyDetails(); $window.scroll(function(){ var viewportHeight=$(window).height(); $(_productGallery).find('.thumbnails > a').each(function(){ var offsetThumbnails=$(this).offset().top; if($window.scrollTop() > offsetThumbnails - viewportHeight + 20){ $(this).addClass('animate-images'); }}); }); $window.on('resize', function(){ stickyDetails(); }); }; learts.crossSells=function(){ if($('.cross-sells .products').find('.product').length < 4){ return; } $('.cross-sells .products').slick({ slidesToShow:4, slidesToScroll: 4, dots:true, responsive:[{ breakpoint: 992, settings:{ slidesToShow:3, slidesToScroll: 3, infinite:true, }, }, { breakpoint: 768, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ dots:false, adaptiveHeight: true, centerMode:true, centerPadding:'40px', slidesToShow:1, slidesToScroll: 1, }, },], }); };})(jQuery); (function($){ "use strict"; var productViewer=function(element){ this.element=element; this.handleContainer=this.element.find('.cd-product-viewer-handle'); this.handleFill=this.handleContainer.children('.fill'); this.handle=this.handleContainer.children('.handle'); this.imageWrapper=this.element.find('.product-viewer'); this.slideShow=this.imageWrapper.children('.product-sprite'); this.frames=this.element.data('frame'); this.friction=this.element.data('friction'); this.visibleFrame=0; this.loaded=false; this.animating=false; this.xPosition=0; this.loadFrames(); } $(".btn-360").on('click', function(e){ e.preventDefault(); var $parent=$('body.single-product'); if($parent.hasClass('active-360')){ $parent.removeClass('active-360'); }else{ $parent.addClass('active-360'); }}); $(".close-360").on('click', function(e){ e.preventDefault(); var $parent=$('body.single-product'); if($parent.hasClass('active-360')){ $parent.removeClass('active-360'); }else{ $parent.addClass('active-360'); }}); productViewer.prototype.loadFrames=function(){ var self=this, imageUrl=this.slideShow.data('image'), newImg=$(''); this.loading('0.5'); newImg.attr('src', imageUrl).load(function(){ $(this).remove(); self.loaded=true; }); } productViewer.prototype.loading=function(percentage){ var self=this; transformElement(this.handleFill, 'scaleX('+ percentage +')'); setTimeout(function(){ if(self.loaded){ self.element.addClass('loaded'); transformElement(self.handleFill, 'scaleX(1)'); self.dragImage(); if(self.handle) self.dragHandle(); }else{ var newPercentage=parseFloat(percentage) + .1; if(newPercentage < 1){ self.loading(newPercentage); }else{ self.loading(parseFloat(percentage)); }} }, 500); } productViewer.prototype.dragHandle=function(){ var self=this; self.handle.on('mousedown vmousedown', function (e){ self.handle.addClass('cd-draggable'); var dragWidth=self.handle.outerWidth(), containerOffset=self.handleContainer.offset().left, containerWidth=self.handleContainer.outerWidth(), minLeft=containerOffset - dragWidth/2, maxLeft=containerOffset + containerWidth - dragWidth/2; self.xPosition=self.handle.offset().left + dragWidth - e.pageX; self.element.on('mousemove vmousemove', function (e){ if(!self.animating){ self.animating=true; (!window.requestAnimationFrame) ? setTimeout(function(){self.animateDraggedHandle(e, dragWidth, containerOffset, containerWidth, minLeft, maxLeft);}, 100) : requestAnimationFrame(function(){self.animateDraggedHandle(e, dragWidth, containerOffset, containerWidth, minLeft, maxLeft);}); }}).one('mouseup vmouseup', function (e){ self.handle.removeClass('cd-draggable'); self.element.off('mousemove vmousemove'); }); e.preventDefault(); }).on('mouseup vmouseup', function (e){ self.handle.removeClass('cd-draggable'); }); } productViewer.prototype.animateDraggedHandle=function(e, dragWidth, containerOffset, containerWidth, minLeft, maxLeft){ var self=this; var leftValue=e.pageX + self.xPosition - dragWidth; if(leftValue < minLeft){ leftValue=minLeft; }else if(leftValue > maxLeft){ leftValue=maxLeft; } var widthValue=Math.ceil((leftValue + dragWidth / 2 - containerOffset) * 1000 / containerWidth)/10; self.visibleFrame=Math.ceil((widthValue * (self.frames-1))/100); self.updateFrame(); $('.cd-draggable', self.handleContainer).css('left', widthValue + '%').one('mouseup vmouseup', function (){ $(this).removeClass('cd-draggable'); }); self.animating=false; } productViewer.prototype.dragImage=function(){ var self=this; self.slideShow.on('mousedown vmousedown', function (e){ self.slideShow.addClass('cd-draggable'); var containerOffset=self.imageWrapper.offset().left, containerWidth=self.imageWrapper.outerWidth(), minFrame=0, maxFrame=self.frames - 1; self.xPosition=e.pageX; self.element.on('mousemove vmousemove', function (e){ if(!self.animating){ self.animating=true; (!window.requestAnimationFrame) ? setTimeout(function(){self.animateDraggedImage(e, containerOffset, containerWidth);}, 100) : requestAnimationFrame(function(){self.animateDraggedImage(e, containerOffset, containerWidth);}); }}).one('mouseup vmouseup', function (e){ self.slideShow.removeClass('cd-draggable'); self.element.off('mousemove vmousemove'); self.updateHandle(); }); e.preventDefault(); }).on('mouseup vmouseup', function (e){ self.slideShow.removeClass('cd-draggable'); }); } productViewer.prototype.animateDraggedImage=function(e, containerOffset, containerWidth){ var self=this; var leftValue=self.xPosition - e.pageX; var widthValue=Math.ceil((leftValue) * 100 /(containerWidth * self.friction)); var frame=(widthValue * (self.frames-1))/100; if(frame > 0){ frame=Math.floor(frame); }else{ frame=Math.ceil(frame); } var newFrame=self.visibleFrame + frame; if(newFrame < 0){ newFrame=self.frames - 1; }else if(newFrame > self.frames - 1){ newFrame=0; } if(newFrame!=self.visibleFrame){ self.visibleFrame=newFrame; self.updateFrame(); self.xPosition=e.pageX; } self.animating=false; } productViewer.prototype.updateHandle=function(){ if(this.handle){ var widthValue=100*this.visibleFrame/this.frames; this.handle.animate({'left': widthValue + '%'}, 200); }} productViewer.prototype.updateFrame=function(){ var transformValue=- (100 * this.visibleFrame/this.frames); transformElement(this.slideShow, 'translateX('+transformValue+'%)'); } function transformElement(element, value){ element.css({ '-moz-transform': value, '-webkit-transform': value, '-ms-transform': value, '-o-transform': value, 'transform': value, }); } var productToursWrapper=$('.cd-product-viewer-wrapper'); productToursWrapper.each(function(){ new productViewer($(this)); }); })(jQuery); ( function($){ "use strict"; var $body=$('body'); learts.swatches=function(){ $('form.isw-swatches.variations_form').on('woocommerce_update_variation_values', function(){ $('select.isw-selectbox').niceSelect('update'); }); $body.on('isw_change_add_to_cart_button_text', function(e, $product){ var text='', $button=$product.find('.add_to_cart_button'); if($button.hasClass('isw-ready')){ text=isw_vars.localization['add_to_cart_text']; }else{ if($button.hasClass('isw-readmore')){ text=isw_vars.localization['read_more_text']; }else{ text=isw_vars.localization['select_options_text']; }} $button.parent().attr('aria-label', text); if($('.add_to_cart_button.isw-text-changed') .closest('.product-loop') .find('.price:not(.price-cloned)') .text().length==0){ text=isw_vars.localization['read_more_text']; $('.add_to_cart_button.isw-text-changed') .removeClass('isw-ready') .text(text) .parent() .attr('aria-label', text); }}); $body.on('isw_reset_add_to_cart_button_text', function(){ $('.add_to_cart_button.isw-text-changed') .parent() .attr('aria-label', isw_vars.localization['select_options_text']); }); }; learts.reInitSwatches=function(){ if(typeof isw!='undefined'&&typeof isw.Swatches!=='undefined'){ isw.Swatches.init(); }};} )(jQuery); ( function($){ "use strict"; var $document=$(document); learts.quantityField=function(){ var build=function(){ $('div.quantity:not(.learts_qty):not(.hidden), td.quantity:not(.learts_qty):not(.hidden)') .addClass('learts_qty') .append('+') .prepend('-'); $('input.qty:not(.product-quantity input.qty)').each(function(){ var min=parseFloat($(this).attr('min')); if(min&&min > 0&&parseFloat($(this).val()) < min){ $(this).val(min); }}); $('.plus, .minus').unbind('click').on('click', function(){ var $qty=$(this).closest('.quantity').find('.qty'), currentVal=parseFloat($qty.val()), max=parseFloat($qty.attr('max')), min=parseFloat($qty.attr('min')), step=$qty.attr('step'); if(! currentVal||currentVal===''||currentVal==='NaN'){ currentVal=0; } if(max===''||max==='NaN'){ max=''; } if(min===''||min==='NaN'){ min=0; } if(step==='any'||step===''||step===undefined||parseFloat(step)==='NaN'){ step=1; } if($(this).is('.plus')){ if(max&&( max==currentVal||currentVal > max )){ $qty.val(max); }else{ $qty.val(currentVal + parseFloat(step)); }}else{ if(min&&( min==currentVal||currentVal < min )){ $qty.val(min); }else if(currentVal > 0){ $qty.val(currentVal - parseFloat(step)); }} $qty.trigger('change'); }); }; build(); $document.ajaxComplete(function(){ build(); }); };} )(jQuery); ( function($){ "use strict"; learts.cookie=function(){ if(Cookies.get('learts_cookie_notice_accepted')=='yes'){ return; } var $cookieWrapper=$('.cookie-wrapper'), expires=parseInt($cookieWrapper.attr('data-expires')); setTimeout(function(){ $cookieWrapper.addClass('animated fadeInUp'); $cookieWrapper.on('click', '.cookie-accept-btn', function(e){ e.preventDefault(); $cookieWrapper.removeClass('fadeInUp').addClass('fadeOutDown'); acceptCookie(expires); }); }, 500); var acceptCookie=function(expires){ Cookies.set('learts_cookie_notice_accepted', 'yes', { expires: expires, path:'/' }); };}; } )(jQuery); (function($){ "use strict"; var $body=$('body'); learts.brand=function(){ var brandFilter=function($el){ if(typeof $el=='undefined'||! $el.length){ return; } var clazz=$el.attr('id'); $el.select2({ templateResult: function(str){ if(! str.id){ return str.text; } return $('' + str.text + ''); }, }); $el.next('.select2').on('mousedown', function(){ $('#select2-' + clazz + '-results').perfectScrollbar(); }); }; brandFilter($('select#pw_brand_category_filter')); brandFilter($('select#pw_brand_category_filter_product')); var events=function(){ $('.wb-wb-allview-letters').unbind('click').on('click', function(e){ e.preventDefault(); var full_url=this.href; var parts=full_url.split("#"), trgt=parts[1], aTag=$("div[id='" + trgt + ""), scrollTo=aTag.offset().top; if(leartsConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } if($('#wpadminbar').length&&$('#wpadminbar').css('position')=='fixed'){ scrollTo -=$('#wpadminbar').height(); } $body.animate({ scrollTop: scrollTo }, 600); }); var $allviewCat=$('.wb-allview-learts').find('.wb-allview-cat-cnt'); $allviewCat.each(function(){ $(this) .append('' + leartsConfigs.go_to_filter_text + ''); }); $('.go-to-filter').on('click', function(e){ e.preventDefault(); var scrollTo=$('.wb-allview-formcnt').offset().top - 30; if(leartsConfigs.sticky_header){ scrollTo -=$('.sticky-header').height(); } if($('#wpadminbar').length&&$('#wpadminbar').css('position')=='fixed'){ scrollTo -=$('#wpadminbar').height(); } $body.animate({ scrollTop: scrollTo }, 600); }); }; events(); brandFilter(); var brandsCarousel=function(){ $('.learts-brands-carousel').each(function(){ var $this=$(this), atts=JSON.parse($this.attr('data-atts')); if(atts==null){ return; } if(typeof atts.auto_play_speed==='undefined'||isNaN(atts.auto_play_speed)){ atts.auto_play_speed=5; } var configs={ accessibility:false, slidesToShow:parseInt(atts.number), slidesToScroll: 1, infinite:( atts.loop=='yes' ), autoplay:( atts.auto_play=='yes' ), autoplaySpeed:parseInt(atts.auto_play_speed) * 1000, adaptiveHeight: true, speed:1000, responsive:[{ breakpoint: 992, settings:{ slidesToShow:2, slidesToScroll: 2, }, }, { breakpoint: 544, settings:{ arrows:true, dots:false, adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, },], }; if(! atts.nav_type){ configs.arrows=false; configs.dots=false; }else{ if(atts.nav_type=='dots'){ configs.arrows=false; configs.dots=true; } if(atts.nav_type=='both'){ configs.arrows=true; configs.dots=true; }} if(parseInt(atts.number_of_images_to_show)==1){ configs.responsive=[{ breakpoint: 992, settings:{ adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, }, { breakpoint: 544, settings:{ arrows:true, dots:false, adaptiveHeight: true, slidesToShow:1, slidesToScroll: 1, }, },]; } $this.slick(configs); $this.slick('setPosition'); }); } brandsCarousel(); };})(jQuery); ( function($){ "use strict"; learts.customJS=function(){ $('.button-video a').magnificPopup({ type:'iframe', mainClass:'mfp-fade', removalDelay:160, preloader:false, fixedContentPos: false }); $('.video-lightbox-btn').magnificPopup({ type:'iframe', mainClass:'mfp-fade', removalDelay:160, preloader:false, fixedContentPos: false }); $('.gif').gifplayer(); $(".learts-image-gallery").lightGallery({ selector:'a', thumbnail:true, animateThumb:false, showThumbByDefault: false }); $(".share-button").on('click', function(){ var $parent=$(this).parents('.post-share'); if($parent.hasClass('active')){ $parent.removeClass('active'); }else{ $parent.addClass('active'); }}); $(".btn-pop-up").on('click', function(){ var $parent=$('.rev_slider'); var $tpRrightArrow=$parent.find('.tp-rightarrow'); var $tpLeftArrow=$parent.find('.tp-leftarrow'); $tpRrightArrow.on('click', function(){ $parent.removeClass('active'); $parent.removeClass('active-popup-1'); $parent.removeClass('active-popup-2'); $parent.removeClass('active-popup-3'); $parent.removeClass('active-popup-4'); }); $tpLeftArrow.on('click', function(){ $parent.removeClass('active'); $parent.removeClass('active-popup-1'); $parent.removeClass('active-popup-2'); $parent.removeClass('active-popup-3'); $parent.removeClass('active-popup-4'); }); if($parent.hasClass('active')){ $parent.removeClass('active'); }else{ $parent.addClass('active'); }}); $(".title-vertical-menu").on('click', function(){ var $verticalMenu=$('.learts-menu-vertical.display-dropdown'); if($verticalMenu.hasClass('active')){ $verticalMenu.removeClass('active'); }else{ $verticalMenu.addClass('active'); }}); $(".wc-proceed-to-checkout").find('.checkout-button').removeClass('alt'); $(".wishlist_table").find('.ajax_add_to_cart').removeClass('alt'); $(".wishlist_table").find('.ajax_add_to_cart').addClass('grey'); $(".single-product").find('.yith-wcwl-add-button').removeClass('hint--left'); $(".single-product").find('.yith-wcwl-add-button').addClass('hint--top'); $(".single-product").find('.compare-btn').removeClass('hint--left'); $(".single-product").find('.compare-btn').addClass('hint--top'); $(".single-product").find('.yith-wcwl-wishlistexistsbrowse').removeClass('hint--left'); $(".single-product").find('.yith-wcwl-wishlistexistsbrowse').addClass('hint--top'); $(".single-product").find('.yith-wcwl-wishlistaddedbrowse').removeClass('hint--left'); $(".single-product").find('.yith-wcwl-wishlistaddedbrowse').addClass('hint--top'); $(".double-product").find('.product').removeClass('col-md-4 col-lg-3'); $(".double-product").find('.product').addClass('col-md-6 col-lg-6'); $('.related').find('.yith-wcwl-add-button').removeClass('hint--top'); $('.related').find('.yith-wcwl-add-button').addClass('hint--left'); $('.related').find('.yith-wcwl-wishlistaddedbrowse').removeClass('hint--top'); $('.related').find('.yith-wcwl-wishlistaddedbrowse').addClass('hint--left'); if('1'===leartsConfigs.effect_snow_fall){ $('body').snowfall({ flakeCount: 50, flaklor :'#fff', flakeIndex: 999999, minSize:10, maxSize:40, minSpeed:1, maxSpeed:5, round:true, shadow:false, image:leartsConfigs.snow_image.url } ); }};} )(jQuery); (function(){ "use strict"; learts.instagram=function(){ var overlaySize=function(){ [].slice.call(document.querySelectorAll('.tm-instagram-pics')).forEach(function(_instagram){ [].slice.call(_instagram.querySelectorAll('.item')).forEach(function(_item){ var _overlay=_item.querySelector('.overlay'), _img=_item.querySelector('.item-image'); setTimeout(function(){ _overlay.style.width=_img.getBoundingClientRect().width + 'px'; _overlay.style.height=_img.getBoundingClientRect().height + 'px'; }, 500); }); }); } overlaySize(); window.addEventListener('resize', function(){ overlaySize(); }); };})(jQuery); (function($){ "use strict"; learts.mailchimpSubscribe=function(){ var _forms=[].slice.call(document.querySelectorAll('.learts-mailchimp .mailchimp-form')); _forms.forEach(function(_form){ _form.addEventListener('submit', function(e){ e.preventDefault(); _form.classList.add('mailchimp-loading'); var _message=_form.parentNode.querySelector('.mailchimp-message'); _message.innerHTML=''; _message.classList.remove('success'); _message.classList.remove('error'); $.ajax({ url:leartsConfigs.ajax_url, type:'POST', data:{ action:'learts_ajax_subscribe', email:_form.querySelector('.mailchimp-email').value, list_id: _form.querySelector('.mailchimp-list-id').value, }, success: function(res){ if(res){ var response=JSON.parse(res); _message.innerHTML=response.message; _message.classList.add(response.action_status ? 'success':'error'); } _form.classList.remove('mailchimp-loading'); }}); }); }); };})(jQuery);